Unified · Split
| @@ -60,7 +60,7 @@ OFILES=\ · 59 unmodified lines | ||
| 60 | 60 | detokenize.$O\ |
| 61 | 61 | # error_concealment.$O\ |
| 62 | 62 | onyxd_if.$O\ |
| 63 | −# threading.$O\ | |
| 63 | + threading.$O\ | |
| 64 | 64 | # vp8/encoder \ |
| 65 | 65 | bitstream.$O\ |
| 66 | 66 | boolhuff.$O\ |
| @@ -0,0 +1,75 @@ | ||
| 1 | +#ifndef __pthread_h__ | |
| 2 | +#define __pthread_h__ | |
| 3 | + | |
| 4 | +typedef struct pthread_t pthread_t; | |
| 5 | +typedef struct pthread_cond_t pthread_cond_t; | |
| 6 | +typedef struct pthread_once_t pthread_once_t; | |
| 7 | +typedef struct pthread_mutex_t pthread_mutex_t; | |
| 8 | + | |
| 9 | +struct pthread_cond_t { | |
| 10 | + Rendez; | |
| 11 | + QLock lock; | |
| 12 | +}; | |
| 13 | + | |
| 14 | +struct pthread_once_t { | |
| 15 | + QLock; | |
| 16 | + int done; | |
| 17 | +}; | |
| 18 | + | |
| 19 | +struct pthread_mutex_t { | |
| 20 | + QLock; | |
| 21 | +}; | |
| 22 | + | |
| 23 | +#define PTHREAD_ONCE_INIT {0} | |
| 24 | + | |
| 25 | +struct pthread_t { | |
| 26 | + void *waitchan; | |
| 27 | + void *(*func)(void*); | |
| 28 | + void *arg; | |
| 29 | + int pid; | |
| 30 | +}; | |
| 31 | + | |
| 32 | +typedef struct { | |
| 33 | + unsigned stack_size; | |
| 34 | +} pthread_attr_t; | |
| 35 | + | |
| 36 | +void dav1d_set_thread_name(const char *const name); | |
| 37 | +int dav1d_pthread_join(pthread_t *thread, void **res); | |
| 38 | +#define pthread_join(thread, res) dav1d_pthread_join(&(thread), res) | |
| 39 | + | |
| 40 | +static int pthread_attr_init(pthread_attr_t *const attr) { | |
| 41 | + attr->stack_size = 0; | |
| 42 | + return 0; | |
| 43 | +} | |
| 44 | + | |
| 45 | +static int pthread_attr_destroy(pthread_attr_t *const attr) { | |
| 46 | + USED(attr); | |
| 47 | + return 0; | |
| 48 | +} | |
| 49 | + | |
| 50 | +static int pthread_attr_setstacksize(pthread_attr_t *const attr, | |
| 51 | + const int stack_size) | |
| 52 | +{ | |
| 53 | + attr->stack_size = stack_size; | |
| 54 | + return 0; | |
| 55 | +} | |
| 56 | + | |
| 57 | +static int | |
| 58 | +pthread_mutex_trylock(pthread_mutex_t *const mutex) | |
| 59 | +{ | |
| 60 | + return canqlock(mutex) ? 0 : -1; | |
| 61 | +} | |
| 62 | + | |
| 63 | +int pthread_mutex_init(pthread_mutex_t *const mutex, const void *const attr); | |
| 64 | +int pthread_mutex_destroy(pthread_mutex_t *const mutex); | |
| 65 | +int pthread_mutex_lock(pthread_mutex_t *const mutex); | |
| 66 | +int pthread_mutex_unlock(pthread_mutex_t *const mutex); | |
| 67 | +int pthread_cond_init(pthread_cond_t *const cond, const void *const attr); | |
| 68 | +int pthread_cond_destroy(pthread_cond_t *const cond); | |
| 69 | +int pthread_cond_wait(pthread_cond_t *const cond, pthread_mutex_t *const mutex); | |
| 70 | +int pthread_cond_signal(pthread_cond_t *const cond); | |
| 71 | +int pthread_cond_broadcast(pthread_cond_t *const cond); | |
| 72 | +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*func)(void*), void *arg); | |
| 73 | +int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)); | |
| 74 | + | |
| 75 | +#endif | |
Empty file added.
| @@ -0,0 +1,50 @@ | ||
| 1 | +#ifndef __semaphore_h__ | |
| 2 | +#define __semaphore_h__ | |
| 3 | + | |
| 4 | +typedef struct sem_t sem_t; | |
| 5 | + | |
| 6 | +struct sem_t { | |
| 7 | + Channel *c; | |
| 8 | +}; | |
| 9 | + | |
| 10 | +static int | |
| 11 | +sem_post(sem_t *s) | |
| 12 | +{ | |
| 13 | + void *p; | |
| 14 | + | |
| 15 | + if(s == nil || s->c == nil) | |
| 16 | + return -1; | |
| 17 | + nbrecv(s->c, &p); | |
| 18 | + | |
| 19 | + return 0; | |
| 20 | +} | |
| 21 | + | |
| 22 | +static int | |
| 23 | +sem_wait(sem_t *s) | |
| 24 | +{ | |
| 25 | + void *p; | |
| 26 | + | |
| 27 | + if(s == nil || s->c == nil) | |
| 28 | + return -1; | |
| 29 | + sendp(s->c, nil); | |
| 30 | + | |
| 31 | + return 0; | |
| 32 | +} | |
| 33 | + | |
| 34 | +static int | |
| 35 | +sem_init(sem_t *s, int pshared, unsigned int value) | |
| 36 | +{ | |
| 37 | + s->c = chancreate(sizeof(void*), value); | |
| 38 | + | |
| 39 | + return 0; | |
| 40 | +} | |
| 41 | + | |
| 42 | +static int | |
| 43 | +sem_destroy(sem_t *s) | |
| 44 | +{ | |
| 45 | + chanclose(s->c); | |
| 46 | + | |
| 47 | + return 0; | |
| 48 | +} | |
| 49 | + | |
| 50 | +#endif | |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | #include <u.h> |
| 13 | 13 | #include <libc.h> |
| 14 | +#include <thread.h> | |
| 14 | 15 | #include </sys/include/stdio.h> |
| 15 | 16 | typedef u8int uint8_t; |
| 16 | 17 | typedef u16int uint16_t; |
| @@ -59,6 +60,14 @@ int gettimeofday(struct timeval *, struct timezone *); · 42 unmodified lines | ||
| 59 | 60 | double round(double); |
| 60 | 61 | #define logf log |
| 61 | 62 | |
| 63 | +#define sched_yield() yield() | |
| 64 | +#define __atomic_load_n(p,o) *(p) | |
| 65 | +#define __atomic_store_n(p,v,x) do { *(p) = (v); } while(0) | |
| 66 | +#define __has_builtin(x) 1 | |
| 67 | + | |
| 68 | +#define __ATOMIC_RELEASE 0 | |
| 69 | +#define __ATOMIC_ACQUIRE 1 | |
| 70 | + | |
| 62 | 71 | #define RESTRICT |
| 63 | 72 | #define INLINE inline |
| 64 | 73 | #define VPX_ARCH_ARM 0 |
| @@ -84,7 +93,7 @@ double round(double); · 19 unmodified lines | ||
| 84 | 93 | #define HAVE_VSX 0 |
| 85 | 94 | #define HAVE_MMI 0 |
| 86 | 95 | #define HAVE_VPX_PORTS 0 |
| 87 | −#define HAVE_PTHREAD_H 0 | |
| 96 | +#define HAVE_PTHREAD_H 1 | |
| 88 | 97 | #define HAVE_UNISTD_H 1 |
| 89 | 98 | #define CONFIG_DEPENDENCY_TRACKING 1 |
| 90 | 99 | #define CONFIG_EXTERNAL_BUILD 0 |
| @@ -107,7 +116,7 @@ double round(double); · 16 unmodified lines | ||
| 107 | 116 | #define CONFIG_RUNTIME_CPU_DETECT 1 |
| 108 | 117 | #define CONFIG_POSTPROC 0 |
| 109 | 118 | #define CONFIG_VP9_POSTPROC 0 |
| 110 | −#define CONFIG_MULTITHREAD 0 | |
| 119 | +#define CONFIG_MULTITHREAD 1 | |
| 111 | 120 | #define CONFIG_INTERNAL_STATS 0 |
| 112 | 121 | #define CONFIG_VP8_ENCODER 1 |
| 113 | 122 | #define CONFIG_VP8_DECODER 1 |
| @@ -122,12 +131,12 @@ double round(double); · 8 unmodified lines | ||
| 122 | 131 | #define CONFIG_REALTIME_ONLY 0 |
| 123 | 132 | #define CONFIG_ONTHEFLY_BITPACKING 0 |
| 124 | 133 | #define CONFIG_ERROR_CONCEALMENT 0 |
| 125 | −#define CONFIG_SHARED 1 | |
| 134 | +#define CONFIG_SHARED 0 | |
| 126 | 135 | #define CONFIG_STATIC 1 |
| 127 | 136 | #define CONFIG_SMALL 0 |
| 128 | 137 | #define CONFIG_POSTPROC_VISUALIZER 0 |
| 129 | 138 | #define CONFIG_OS_SUPPORT 1 |
| 130 | −#define CONFIG_UNIT_TESTS 1 | |
| 139 | +#define CONFIG_UNIT_TESTS 0 | |
| 131 | 140 | #define CONFIG_WEBM_IO 0 |
| 132 | 141 | #define CONFIG_LIBYUV 0 |
| 133 | 142 | #define CONFIG_DECODE_PERF_TESTS 0 |
| @@ -36,7 +36,7 @@ typedef void(WINAPI *PGNSI)(LPSYSTEM_INFO); · 35 unmodified lines | ||
| 36 | 36 | #endif |
| 37 | 37 | |
| 38 | 38 | #if CONFIG_MULTITHREAD |
| 39 | −static int get_cpu_count() { | |
| 39 | +static int get_cpu_count(void) { | |
| 40 | 40 | int core_count = 16; |
| 41 | 41 | |
| 42 | 42 | #if HAVE_UNISTD_H && !defined(__OS2__) |
| @@ -79,6 +79,12 @@ static int get_cpu_count() { · 36 unmodified lines | ||
| 79 | 79 | if (status == PROC_ONLINE) core_count++; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | +#elif defined(__plan9__) | |
| 83 | + { | |
| 84 | + char *s = getenv("NPROC"); | |
| 85 | + core_count = atoi(s ? s : "1"); | |
| 86 | + fprint(2, "core count: %d\n", core_count); | |
| 87 | + } | |
| 82 | 88 | #else |
| 83 | 89 | /* other platforms */ |
| 84 | 90 | #endif |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <assert.h> |
| 12 | 12 | #include <stdlib.h> |
| 13 | 13 | #include <string.h> |
| 14 | +#include "vpx_config.h" | |
| 14 | 15 | #include "./vp8_rtcd.h" |
| 15 | 16 | #include "./vpx_dsp_rtcd.h" |
| 16 | 17 | #include "./vpx_scale_rtcd.h" |
| @@ -48,6 +48,7 @@ · 47 unmodified lines | ||
| 48 | 48 | #define HToBE32(X) BSwap32(X) |
| 49 | 49 | #endif |
| 50 | 50 | |
| 51 | +#ifndef __plan9__ | |
| 51 | 52 | #if LOCAL_GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16) |
| 52 | 53 | #define HAVE_BUILTIN_BSWAP16 |
| 53 | 54 | #endif |
| @@ -59,6 +60,7 @@ · 5 unmodified lines | ||
| 59 | 60 | #if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64) |
| 60 | 61 | #define HAVE_BUILTIN_BSWAP64 |
| 61 | 62 | #endif |
| 63 | +#endif | |
| 62 | 64 | |
| 63 | 65 | #if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \ |
| 64 | 66 | defined(__mips_isa_rev) && (__mips_isa_rev >= 2) && (__mips_isa_rev < 6) |
| @@ -383,6 +383,7 @@ typedef int (*VPxWorkerHook)(void *, void *); · 382 unmodified lines | ||
| 383 | 383 | |
| 384 | 384 | // Platform-dependent implementation details for the worker. |
| 385 | 385 | typedef struct VPxWorkerImpl VPxWorkerImpl; |
| 386 | +#pragma incomplete VPxWorkerImpl | |
| 386 | 387 | |
| 387 | 388 | // Synchronization object used to launch job in the worker thread |
| 388 | 389 | typedef struct { |
| @@ -393,6 +394,7 @@ typedef struct { · 4 unmodified lines | ||
| 393 | 394 | void *data2; // second argument passed to 'hook' |
| 394 | 395 | int had_error; // return value of the last call to 'hook' |
| 395 | 396 | } VPxWorker; |
| 397 | +#pragma incomplete VPxWorker | |
| 396 | 398 | |
| 397 | 399 | // The interface for all thread-worker related functions. All these functions |
| 398 | 400 | // must be implemented. |
| @@ -418,6 +420,7 @@ typedef struct { · 19 unmodified lines | ||
| 418 | 420 | // must call reset() again. |
| 419 | 421 | void (*end)(VPxWorker *const worker); |
| 420 | 422 | } VPxWorkerInterface; |
| 423 | +#pragma incomplete VPxWorkerInterface | |
| 421 | 424 | |
| 422 | 425 | // Install a new set of threading functions, overriding the defaults. This |
| 423 | 426 | // should be done before any workers are started, i.e., before any encoding or |