Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2208 → Rev 2209

/trunk/uspace/kbd/generic/key_buffer.c
111,4 → 111,3
/**
* @}
*/
 
/trunk/uspace/libc/include/async.h
116,12 → 116,13
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,5 → 56,3
 
/** @}
*/
/trunk/uspace/libc/generic/io/io.c
37,18 → 37,17
#include <stdio.h>
#include <io/io.h>
 
static char nl = '\n';
const 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;
}
61,11 → 60,10
* @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;
}
73,18 → 71,16
/** 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;
}
92,9 → 88,8
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;
}
102,9 → 97,8
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,10 → 36,11
#include <stdio.h>
#include <unistd.h>
#include <io/printf_core.h>
#include <futex.h>
 
int vprintf_write(const char *str, size_t count, void *unused);
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)
{
return write(1, str, count);
}
51,9 → 52,13
*/
int vprintf(const char *fmt, va_list ap)
{
struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL};
return printf_core(fmt, &ps, 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;
}
 
/** @}
/trunk/uspace/libc/generic/io/vsnprintf.c
43,8 → 43,6
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
55,7 → 53,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!)
*/
int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
{
size_t i;
i = data->size - data->len;
97,7 → 95,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,8 → 40,6
#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 */
92,15 → 90,13
{
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;
}
447,9 → 443,6
int width, precision;
uint64_t flags;
/* Don't let other threads interfere */
async_serialize_start();
 
counter = 0;
while ((c = fmt[i])) {
681,10 → 674,8
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);
}
 
/** @}