/uspace/trunk/fb/sysio.c |
---|
120,7 → 120,6 |
ipc_answer_fast(iid, ELIMIT, 0,0); |
return; |
} |
client_connected = 1; |
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
while (1) { |
134,7 → 133,7 |
c = IPC_GET_ARG1(call); |
newrow = IPC_GET_ARG2(call); |
newcol = IPC_GET_ARG3(call); |
if ((lastcol != newcol) || (lastrow != newrow)) |
if (lastcol != newcol || lastrow!=newrow) |
curs_goto(newrow, newcol); |
lastcol = newcol + 1; |
lastrow = newrow; |
147,7 → 146,6 |
curs_goto(newrow, newcol); |
lastrow = newrow; |
lastcol = newcol; |
retval = 0; |
break; |
case FB_GET_CSIZE: |
ipc_answer_fast(callid, 0, HEIGHT, WIDTH); |
167,7 → 165,7 |
break; |
case FB_SCROLL: |
i = IPC_GET_ARG1(call); |
if ((i > HEIGHT) || (i < -HEIGHT)) { |
if (i > HEIGHT || i < -HEIGHT) { |
retval = EINVAL; |
break; |
} |
175,10 → 173,10 |
curs_goto(lastrow, lastcol); |
retval = 0; |
break; |
default: |
retval = ENOENT; |
} |
ipc_answer_fast(callid, retval, 0, 0); |
} |
} |
196,3 → 194,4 |
/** |
* @} |
*/ |
/uspace/trunk/libc/generic/psthread.c |
---|
51,6 → 51,7 |
static LIST_INITIALIZE(serialized_list); |
static LIST_INITIALIZE(manager_list); |
static void psthread_exit(void) __attribute__ ((noinline)); |
static void psthread_main(void); |
static atomic_t psthread_futex = FUTEX_INITIALIZER; |
190,7 → 191,7 |
*/ |
int psthread_join(pstid_t psthrid) |
{ |
volatile psthread_data_t *pt; |
volatile psthread_data_t *pt, *mypt; |
volatile int retval; |
/* Handle psthrid = Kernel address -> it is wait for call */ |
237,7 → 238,8 |
pt->flags = 0; |
context_save(&pt->ctx); |
context_set(&pt->ctx, FADDR(psthread_main), pt->stack, PSTHREAD_INITIAL_STACK_PAGES_NO*getpagesize(), pt->tcb); |
context_set(&pt->ctx, FADDR(psthread_main), pt->stack, PSTHREAD_INITIAL_STACK_PAGES_NO*getpagesize(), |
pt->tcb); |
return (pstid_t )pt; |
} |
307,3 → 309,5 |
/** @} |
*/ |
/uspace/trunk/libc/generic/time.c |
---|
73,7 → 73,9 |
if (!ktime) { |
mapping = as_get_mappable_page(PAGE_SIZE); |
/* Get the mapping of kernel clock */ |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, NULL); |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, |
NULL,&rights,NULL); |
if (res) { |
printf("Failed to initialize timeofday memarea\n"); |
_exit(1); |
117,3 → 119,5 |
/** @} |
*/ |
/uspace/trunk/libc/generic/async.c |
---|
373,13 → 373,11 |
/* Setup thread local connection pointer */ |
PS_connection = (connection_t *)arg; |
PS_connection->cthread(PS_connection->callid, &PS_connection->call); |
/* Remove myself from connection hash table */ |
futex_down(&async_futex); |
key = PS_connection->in_phone_hash; |
hash_table_remove(&conn_hash_table, &key, 1); |
futex_up(&async_futex); |
/* Answer all remaining messages with ehangup */ |
while (!list_empty(&PS_connection->msg_queue)) { |
msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link); |
391,8 → 389,6 |
} |
if (PS_connection->close_callid) |
ipc_answer_fast(PS_connection->close_callid, 0, 0, 0); |
return 0; |
} |
/** Create new thread for a new connection |
409,8 → 405,11 |
* opening the connection |
* @return New thread id |
*/ |
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *)) |
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, |
ipc_call_t *call, |
void (*cthread)(ipc_callid_t,ipc_call_t *)) |
{ |
pstid_t ptid; |
connection_t *conn; |
unsigned long key; |
515,8 → 514,7 |
while (1) { |
if (psthread_schedule_next_adv(PS_FROM_MANAGER)) { |
futex_up(&async_futex); |
/* async_futex is always held |
futex_up(&async_futex); /* async_futex is always held |
* when entering manager thread |
*/ |
continue; |
548,8 → 546,6 |
handle_call(callid, &call); |
} |
return 0; |
} |
/** Function to start async_manager as a standalone thread |
561,12 → 557,9 |
*/ |
static int async_manager_thread(void *arg) |
{ |
futex_up(&async_futex); |
/* async_futex is always locked when entering |
futex_up(&async_futex); /* async_futex is always locked when entering |
* manager */ |
async_manager_worker(); |
return 0; |
} |
/** Add one manager to manager list */ |
592,7 → 585,6 |
return ENOMEM; |
} |
return 0; |
} |
/** IPC handler for messages in async framework |
687,6 → 679,7 |
void async_wait_for(aid_t amsgid, ipcarg_t *retval) |
{ |
amsg_t *msg = (amsg_t *) amsgid; |
connection_t *conn; |
futex_down(&async_futex); |
if (msg->done) { |
718,6 → 711,7 |
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout) |
{ |
amsg_t *msg = (amsg_t *) amsgid; |
connection_t *conn; |
/* TODO: Let it go through the event read at least once */ |
if (timeout < 0) |
810,3 → 804,5 |
/** @} |
*/ |
/uspace/trunk/libc/generic/libc.c |
---|
25,7 → 25,6 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup lc Libc |
* @brief HelenOS C library |
* @{ |
50,13 → 49,11 |
extern char _heap; |
void _exit(int status) |
{ |
void _exit(int status) { |
thread_exit(status); |
} |
void __main(void) |
{ |
void __main(void) { |
psthread_data_t *pt; |
(void) as_area_create(&_heap, 1, AS_AREA_WRITE | AS_AREA_READ); |
65,18 → 62,19 |
__tcb_set(pt->tcb); |
} |
void __io_init(void) |
{ |
void __io_init(void) { |
open("stdin", 0); |
open("stdout", 0); |
open("stderr", 0); |
} |
void __exit(void) |
{ |
void __exit(void) { |
psthread_teardown(__tcb_get()->pst_data); |
_exit(0); |
} |
/** @} |
*/ |
/uspace/trunk/libc/generic/ddi.c |
---|
69,6 → 69,7 |
*/ |
int iospace_enable(task_id_t id, void *ioaddr, unsigned long size) |
{ |
task_id_t task_id; |
ddi_ioarg_t arg; |
arg.task_id = id; |
90,3 → 91,5 |
/** @} |
*/ |
/uspace/trunk/libc/generic/cap.c |
---|
52,7 → 52,7 |
arg.value = (unsigned long long) id; |
return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); |
__SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); |
} |
/** Revoke capabilities from a task. |
68,9 → 68,11 |
arg.value = (unsigned long long) id; |
return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); |
__SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); |
} |
/** @} |
*/ |
/uspace/trunk/libc/generic/as.c |
---|
92,22 → 92,17 |
{ |
int rc; |
void *res; |
/* Check for invalid values */ |
if (incr < 0 && -incr > heapsize) |
return NULL; |
/* Check for too large value */ |
if (incr > 0 && incr+heapsize < heapsize) |
return NULL; |
/* Check for too small values */ |
if (incr < 0 && incr+heapsize > heapsize) |
return NULL; |
/* Check for user limit */ |
if ((maxheapsize != (size_t) (-1)) && (heapsize + incr) > maxheapsize) |
return NULL; |
if ((maxheapsize!=(size_t)(-1)) && (heapsize + incr)>maxheapsize) return NULL; |
rc = as_area_resize(&_heap, heapsize + incr, 0); |
if (rc != 0) |
126,7 → 121,7 |
{ |
maxheapsize = mhs; |
/* Return pointer to area not managed by sbrk */ |
return ((void *) &_heap + maxheapsize); |
return (void *)&_heap + maxheapsize; |
} |
142,9 → 137,8 |
/* Set heapsize to some meaningful value */ |
if (maxheapsize == -1) |
set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH >> 1, PAGE_SIZE)); |
if (!last_allocated) |
last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE); |
last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE); |
sz = ALIGN_UP(sz, PAGE_SIZE); |
res = last_allocated; |
153,5 → 147,8 |
return res; |
} |
/** @} |
*/ |
/uspace/trunk/libc/generic/string.c |
---|
44,16 → 44,12 |
void *memset(void *s, int c, size_t n) |
{ |
char *os = s; |
while (n--) |
*(os++) = c; |
return s; |
} |
struct along { |
unsigned long n; |
} __attribute__ ((packed)); |
struct along {unsigned long n; } __attribute__ ((packed)); |
static void *unaligned_memcpy(void *dst, const void *src, size_t n) |
{ |
94,7 → 90,7 |
return memcpy(dst, src, n); |
for (j = (n % sizeof(unsigned long)) - 1; j >= 0; j--) |
((unsigned char *) ((unsigned long *) dst))[j] = ((unsigned char *) ((unsigned long *) src))[j]; |
((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j]; |
for (i = n / sizeof(unsigned long) - 1; i >=0 ; i--) |
((unsigned long *) dst)[i] = ((unsigned long *) src)[i]; |
111,8 → 107,9 |
{ |
size_t counter = 0; |
while (str[counter] != 0) |
while (str[counter] != 0) { |
counter++; |
} |
return counter; |
} |
121,14 → 118,14 |
{ |
int c = 0; |
while (a[c] && b[c] && (!(a[c] - b[c]))) |
c++; |
while(a[c]&&b[c]&&(!(a[c]-b[c]))) c++; |
return (a[c] - b[c]); |
return a[c]-b[c]; |
} |
/** Return pointer to the first occurence of character c in string |
* @param str scanned string |
* @param c searched character (taken as one byte) |
300,20 → 297,18 |
char *strcpy(char *dest, const char *src) |
{ |
char *orig = dest; |
while ((*(dest++) = *(src++))); |
return orig; |
while (*(dest++) = *(src++)) |
; |
} |
char *strncpy(char *dest, const char *src, size_t n) |
{ |
char *orig = dest; |
while ((*(dest++) = *(src++)) && --n); |
return orig; |
while ((*(dest++) = *(src++)) && --n) |
; |
} |
/** @} |
*/ |
/uspace/trunk/libc/generic/io/stream.c |
---|
81,6 → 81,7 |
static ssize_t write_stdout(void *param, const void *buf, size_t count) |
{ |
int i; |
ipcarg_t r0,r1; |
for (i = 0; i < count; i++) |
async_msg(streams[1].phone, CONSOLE_PUTCHAR, ((const char *) buf)[i]); |
89,9 → 90,12 |
} |
static stream_t open_stdin(void) |
{ |
stream_t stream; |
int phoneid; |
int res; |
if (console_phone < 0) { |
while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) { |
100,7 → 104,6 |
} |
stream.r = read_stdin; |
stream.w = NULL; |
stream.param = 0; |
stream.phone = console_phone; |
110,6 → 113,7 |
static stream_t open_stdout(void) |
{ |
stream_t stream; |
int res; |
if (console_phone < 0) { |
while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) { |
117,11 → 121,9 |
} |
} |
stream.r = NULL; |
stream.w = write_stdout; |
stream.phone = console_phone; |
stream.param = 0; |
return stream; |
} |
137,7 → 139,6 |
while (((streams[c].w) || (streams[c].r)) && (c < FDS)) |
c++; |
if (c == FDS) |
return EMFILE; |
155,13 → 156,10 |
streams[c].w = write_stderr; |
return c; |
} |
if (!strcmp(fname, "null")) { |
streams[c].w = write_null; |
return c; |
} |
return -1; |
} |
193,3 → 191,5 |
/** @} |
*/ |
/uspace/trunk/libc/generic/err.c |
---|
35,13 → 35,14 |
#include <stdio.h> |
#include <stdlib.h> |
/* TODO |
void errx(int __status, __const char *__format, ...) |
{ |
printf("TODO...errx\n"); |
_exit(0); |
} |
*/ |
/** @} |
*/ |
/uspace/trunk/libc/generic/mmap.c |
---|
36,8 → 36,11 |
#include <as.h> |
#include <unistd.h> |
void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) |
void *mmap(void *start, size_t length, int prot, int flags, int fd, |
off_t offset) |
{ |
int rc; |
if (!start) |
start = as_get_mappable_page(length); |
57,3 → 60,5 |
/** @} |
*/ |
/uspace/trunk/libc/include/err.h |
---|
35,10 → 35,7 |
#ifndef _libc__ERR_H_ |
#define _libc__ERR_H_ |
#define errx(status, fmt, ...) { \ |
printf((fmt), ##__VA_ARGS__); \ |
_exit(status); \ |
} |
#define errx(status,fmt,...) { printf((fmt),##__VA_ARGS__);_exit(status);} |
#endif |
45,3 → 42,5 |
/** @} |
*/ |
/uspace/trunk/libc/include/libc.h |
---|
45,12 → 45,16 |
#define __SYSCALL4(id, p1, p2, p3, p4) __syscall(p1, p2, p3, p4, id) |
extern void __main(void); |
extern void __io_init(void); |
extern void __exit(void); |
extern sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3, const sysarg_t p4, const syscall_t id); |
extern sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, |
const sysarg_t p3, const sysarg_t p4, |
const syscall_t id); |
#endif |
/** @} |
*/ |
/uspace/trunk/libc/Makefile.toolchain |
---|
27,7 → 27,7 |
# |
DEFS = -DARCH=$(ARCH) |
CFLAGS = -fno-builtin -Wall -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include |
CFLAGS = -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include |
LFLAGS = -M -N $(SOFTINT_PREFIX)/libsoftint.a |
AFLAGS = |
#-Werror |
/uspace/trunk/libc/malloc/malloc.c |
---|
2930,9 → 2930,10 |
if (HAVE_MMAP && |
sp->size >= extra && |
!has_segment_link(m, sp)) { /* can't shrink if pinned */ |
size_t newsize = sp->size - extra; |
/* Prefer mremap, fall back to munmap */ |
if ((CALL_MREMAP(sp->base, sp->size, sp->size - extra, 0) != MFAIL) || |
(CALL_MUNMAP(sp->base + sp->size - extra, extra) == 0)) { |
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || |
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) { |
released = extra; |
} |
} |
/uspace/trunk/ns/ns.c |
---|
81,6 → 81,8 |
ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
} hashed_service_t; |
int static ping_phone; |
static void *clockaddr = NULL; |
static void *klogaddr = NULL; |
104,8 → 106,9 |
{ |
ipc_call_t call; |
ipc_callid_t callid; |
char *as_area; |
ipcarg_t retval; |
ipcarg_t retval, arg1, arg2; |
if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, &ns_hash_table_ops)) { |
return ENOMEM; |
146,7 → 149,7 |
break; |
} |
if (! (callid & IPC_CALLID_NOTIFICATION)) { |
ipc_answer_fast(callid, retval, 0, 0); |
ipc_answer_fast(callid, retval, arg1, arg2); |
} |
} |
} |
254,7 → 257,6 |
assert(item); |
free(hash_table_get_instance(item, hashed_service_t, link)); |
} |
/** |
* @} |
*/ |