/branches/rcu/uspace/tester/thread/thread1.def |
---|
File deleted |
/branches/rcu/uspace/tester/thread/thread1.c |
---|
File deleted |
/branches/rcu/uspace/tester/tester.c |
---|
File deleted |
/branches/rcu/uspace/tester/fault/fault1.def |
---|
File deleted |
/branches/rcu/uspace/tester/fault/fault2.def |
---|
File deleted |
/branches/rcu/uspace/tester/fault/fault1.c |
---|
File deleted |
/branches/rcu/uspace/tester/fault/fault2.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/register.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/send_sync.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/send_async.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/hangup.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/register.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/connect.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/send_sync.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/send_async.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/connect.c |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/answer.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/hangup.def |
---|
File deleted |
/branches/rcu/uspace/tester/ipc/answer.c |
---|
File deleted |
/branches/rcu/uspace/tester/print/print1.def |
---|
File deleted |
/branches/rcu/uspace/tester/print/print1.c |
---|
File deleted |
/branches/rcu/uspace/tester/tester.h |
---|
File deleted |
/branches/rcu/uspace/tester/Makefile |
---|
File deleted |
/branches/rcu/uspace/fb/fb.c |
---|
833,27 → 833,23 |
copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) |
{ |
int y; |
int tmp, srcrowsize; |
int realwidth, realheight, realrowsize; |
int rowsize; |
int tmp; |
int width = vport->width; |
int height = vport->height; |
if (width + vport->x > screen.xres) |
width = screen.xres - vport->x; |
if (height + vport->y > screen.yres) |
if (height + vport->y > screen.yres) |
height = screen.yres - vport->y; |
realwidth = pmap->width <= width ? pmap->width : width; |
realheight = pmap->height <= height ? pmap->height : height; |
srcrowsize = vport->width * screen.pixelbytes; |
realrowsize = realwidth * screen.pixelbytes; |
for (y = 0; y < realheight; y++) { |
rowsize = width * screen.pixelbytes; |
for (y = 0; y < height; y++) { |
tmp = (vport->y + y) * screen.scanline + |
vport->x * screen.pixelbytes; |
memcpy(pmap->data + srcrowsize * y, screen.fbaddress + tmp, |
realrowsize); |
memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp, |
rowsize); |
} |
} |
/branches/rcu/uspace/libc/include/async.h |
---|
116,13 → 116,12 |
void async_msg_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, |
ipcarg_t arg3); |
void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2); |
#define async_msg(ph, m, a1) async_msg_2(ph, m, a1, 0) |
#define async_msg(ph,m,a1) async_msg_2(ph,m,a1,0) |
static inline void async_serialize_start(void) |
{ |
psthread_inc_sercount(); |
} |
static inline void async_serialize_end(void) |
{ |
psthread_dec_sercount(); |
/branches/rcu/uspace/libc/include/unistd.h |
---|
44,9 → 44,8 |
extern ssize_t write(int fd, const void * buf, size_t count); |
extern ssize_t read(int fd, void * buf, size_t count); |
extern void _exit(int status); |
extern void *sbrk(ssize_t incr); |
extern void usleep(unsigned long usec); |
extern unsigned int sleep(unsigned int seconds); |
void *sbrk(ssize_t incr); |
void usleep(unsigned long usec); |
#endif |
/branches/rcu/uspace/libc/include/thread.h |
---|
39,16 → 39,11 |
#include <libarch/thread.h> |
#include <types.h> |
typedef uint64_t thread_id_t; |
extern void __thread_entry(void); |
extern void __thread_main(uspace_arg_t *uarg); |
extern int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid); |
extern int thread_create(void (* function)(void *arg), void *arg, char *name); |
extern void thread_exit(int status); |
extern void thread_detach(thread_id_t thread); |
extern int thread_join(thread_id_t thread); |
extern thread_id_t thread_get_id(void); |
extern tcb_t * __make_tls(void); |
extern tcb_t * __alloc_tls(void **data, size_t size); |
extern void __free_tls(tcb_t *); |
/branches/rcu/uspace/libc/generic/time.c |
---|
108,31 → 108,14 |
return 0; |
} |
/** Wait unconditionally for specified number of microseconds */ |
/** Wait unconditionally for specified microseconds */ |
void usleep(unsigned long usec) |
{ |
atomic_t futex = FUTEX_INITIALIZER; |
futex_initialize(&futex, 0); |
futex_initialize(&futex,0); |
futex_down_timeout(&futex, usec, 0); |
} |
/** Wait unconditionally for specified number of seconds */ |
unsigned int sleep(unsigned int seconds) |
{ |
atomic_t futex = FUTEX_INITIALIZER; |
futex_initialize(&futex, 0); |
/* Sleep in 1000 second steps to support |
full argument range */ |
while (seconds > 0) { |
unsigned int period = (seconds > 1000) ? 1000 : seconds; |
futex_down_timeout(&futex, period * 1000000, 0); |
seconds -= period; |
} |
} |
/** @} |
*/ |
/branches/rcu/uspace/libc/generic/thread.c |
---|
124,11 → 124,10 |
* @param function Function implementing the thread. |
* @param arg Argument to be passed to thread. |
* @param name Symbolic name of the thread. |
* @param tid Thread ID of the newly created thread. |
* |
* @return Zero on success or a code from @ref errno.h on failure. |
* @return TID of the new thread on success or -1 on failure. |
*/ |
int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid) |
int thread_create(void (* function)(void *), void *arg, char *name) |
{ |
char *stack; |
uspace_arg_t *uarg; |
149,7 → 148,7 |
uarg->uspace_thread_arg = arg; |
uarg->uspace_uarg = uarg; |
return __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, (sysarg_t) tid); |
return __SYSCALL2(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name); |
} |
/** Terminate current thread. |
161,40 → 160,5 |
__SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status); |
} |
/** Detach thread. |
* |
* Currently not implemented. |
* |
* @param thread TID. |
*/ |
void thread_detach(thread_id_t thread) |
{ |
} |
/** Join thread. |
* |
* Currently not implemented. |
* |
* @param thread TID. |
* |
* @return Thread exit status. |
*/ |
int thread_join(thread_id_t thread) |
{ |
} |
/** Get current thread ID. |
* |
* @return Current thread ID. |
*/ |
thread_id_t thread_get_id(void) |
{ |
thread_id_t thread_id; |
(void) __SYSCALL1(SYS_THREAD_GET_ID, (sysarg_t) &thread_id); |
return thread_id; |
} |
/** @} |
*/ |
/branches/rcu/uspace/libc/generic/io/printf.c |
---|
56,3 → 56,5 |
/** @} |
*/ |
/branches/rcu/uspace/libc/generic/io/io.c |
---|
37,17 → 37,18 |
#include <stdio.h> |
#include <io/io.h> |
const static char nl = '\n'; |
static char nl = '\n'; |
int puts(const char *str) |
int puts(const char * str) |
{ |
size_t count; |
if (str == NULL) |
return putnchars("(NULL)", 6); |
if (str == NULL) { |
return putnchars("(NULL)",6 ); |
} |
for (count = 0; str[count] != 0; count++); |
if (write(1, (void *) str, count) == count) { |
if (write(1, (void * ) str, count) == count) { |
if (write(1, &nl, 1) == 1) |
return 0; |
} |
60,10 → 61,11 |
* @param count |
* @return 0 on succes, EOF on fail |
*/ |
int putnchars(const char *buf, size_t count) |
int putnchars(const char * buf, size_t count) |
{ |
if (write(1, (void *) buf, count) == count) |
if (write(1, (void * ) buf, count) == count) { |
return 0; |
} |
return EOF; |
} |
71,16 → 73,18 |
/** Same as puts, but does not print newline at end |
* |
*/ |
int putstr(const char *str) |
int putstr(const char * str) |
{ |
size_t count; |
if (str == NULL) |
return putnchars("(NULL)", 6); |
if (str == NULL) { |
return putnchars("(NULL)",6 ); |
} |
for (count = 0; str[count] != 0; count++); |
if (write(1, (void *) str, count) == count) |
if (write(1, (void * ) str, count) == count) { |
return 0; |
} |
return EOF; |
} |
88,8 → 92,9 |
int putchar(int c) |
{ |
unsigned char ch = c; |
if (write(1, (void *) &ch, 1) == 1) |
if (write(1, (void *)&ch , 1) == 1) { |
return c; |
} |
return EOF; |
} |
97,8 → 102,9 |
int getchar(void) |
{ |
unsigned char c; |
if (read(0, (void *) &c, 1) == 1) |
if (read(0, (void *)&c , 1) == 1) { |
return c; |
} |
return EOF; |
} |
/branches/rcu/uspace/libc/generic/io/vprintf.c |
---|
36,12 → 36,10 |
#include <stdio.h> |
#include <unistd.h> |
#include <io/printf_core.h> |
#include <futex.h> |
#include <async.h> |
static atomic_t printf_futex = FUTEX_INITIALIZER; |
int vprintf_write(const char *str, size_t count, void *unused); |
static int vprintf_write(const char *str, size_t count, void *unused) |
int vprintf_write(const char *str, size_t count, void *unused) |
{ |
return write(1, str, count); |
} |
53,23 → 51,9 |
*/ |
int vprintf(const char *fmt, va_list ap) |
{ |
struct printf_spec ps = { |
(int (*)(void *, size_t, void *)) vprintf_write, |
NULL |
}; |
/* |
* Prevent other threads to execute printf_core() |
*/ |
futex_down(&printf_futex); |
/* |
* Prevent other pseudo threads of the same thread |
* to execute printf_core() |
*/ |
async_serialize_start(); |
int ret = printf_core(fmt, &ps, ap); |
async_serialize_end(); |
futex_up(&printf_futex); |
return ret; |
struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL}; |
return printf_core(fmt, &ps, ap); |
} |
/** @} |
/branches/rcu/uspace/libc/generic/io/vsnprintf.c |
---|
43,6 → 43,8 |
char *string; /* destination string */ |
}; |
int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data); |
/** Write string to given buffer. |
* Write at most data->size characters including trailing zero. According to C99 has snprintf to return number |
* of characters that would have been written if enough space had been available. Hence the return value is not |
53,7 → 55,7 |
* @param data structure with destination string, counter of used space and total string size. |
* @return number of characters to print (not characters really printed!) |
*/ |
static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
{ |
size_t i; |
i = data->size - data->len; |
95,7 → 97,7 |
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) |
{ |
struct vsnprintf_data data = {size, 0, str}; |
struct printf_spec ps = {(int(*)(void *, size_t, void *)) vsnprintf_write, &data}; |
struct printf_spec ps = {(int(*)(void *, size_t, void *))vsnprintf_write, &data}; |
/* Print 0 at end of string - fix the case that nothing will be printed */ |
if (size > 0) |
/branches/rcu/uspace/libc/generic/io/printf_core.c |
---|
40,6 → 40,8 |
#include <io/printf_core.h> |
#include <ctype.h> |
#include <string.h> |
/* For serialization */ |
#include <async.h> |
#define __PRINTF_FLAG_PREFIX 0x00000001 /**< show prefixes 0x or 0*/ |
#define __PRINTF_FLAG_SIGNED 0x00000002 /**< signed / unsigned number */ |
90,13 → 92,15 |
{ |
size_t count; |
if (str == NULL) |
if (str == NULL) { |
return printf_putnchars("(NULL)", 6, ps); |
} |
for (count = 0; str[count] != 0; count++); |
if (ps->write((void *) str, count, ps->data) == count) |
if (ps->write((void *) str, count, ps->data) == count) { |
return 0; |
} |
return EOF; |
} |
443,6 → 447,9 |
int width, precision; |
uint64_t flags; |
/* Don't let other threads interfere */ |
async_serialize_start(); |
counter = 0; |
while ((c = fmt[i])) { |
674,8 → 681,10 |
counter += retval; |
} |
async_serialize_end(); |
return counter; |
minus_out: |
async_serialize_end(); |
return -counter; |
} |
/branches/rcu/uspace/libc/generic/io/vsprintf.c |
---|
44,7 → 44,7 |
*/ |
int vsprintf(char *str, const char *fmt, va_list ap) |
{ |
return vsnprintf(str, (size_t) - 1, fmt, ap); |
return vsnprintf(str, (size_t)-1, fmt, ap); |
} |
/** @} |
/branches/rcu/uspace/libc/arch/sparc64/include/atomic.h |
---|
51,11 → 51,9 |
uint64_t a, b; |
do { |
volatile uintptr_t x = (uint64_t) &val->count; |
a = *((uint64_t *) x); |
a = val->count; |
b = a + i; |
asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a)); |
asm volatile ("casx %0, %2, %1\n" : "+m" (*val), "+r" (b) : "r" (a)); |
} while (a != b); |
return a; |
/branches/rcu/uspace/libc/arch/sparc64/src/thread_entry.s |
---|
34,7 → 34,7 |
# |
# |
__thread_entry: |
sethi %hi(_gp), %l7 |
sethi %hi(_gp), %l7 |
call __thread_main ! %o0 contains address of uarg |
or %l7, %lo(_gp), %l7 |
/branches/rcu/uspace/kbd/generic/key_buffer.c |
---|
111,3 → 111,4 |
/** |
* @} |
*/ |
/branches/rcu/uspace/Makefile |
---|
41,7 → 41,7 |
kbd \ |
console \ |
tetris \ |
tester \ |
ipcc \ |
klog \ |
rd \ |
fs |