Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2209 → Rev 2208

/trunk/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();
/trunk/uspace/libc/generic/io/printf.c
56,3 → 56,5
 
/** @}
*/
/trunk/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;
}
/trunk/uspace/libc/generic/io/vprintf.c
36,11 → 36,10
#include <stdio.h>
#include <unistd.h>
#include <io/printf_core.h>
#include <futex.h>
 
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);
}
52,13 → 51,9
*/
int vprintf(const char *fmt, va_list ap)
{
struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL};
futex_down(&printf_futex);
int ret = printf_core(fmt, &ps, ap);
futex_up(&printf_futex);
return ret;
struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL};
return printf_core(fmt, &ps, ap);
 
}
 
/** @}
/trunk/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)
/trunk/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;
}
 
/trunk/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);
}
 
/** @}
/trunk/uspace/kbd/generic/key_buffer.c
111,3 → 111,4
/**
* @}
*/