Changeset 4e2cf8b in mainline


Ignore:
Timestamp:
2006-03-14T12:14:43Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ba1db5
Parents:
df50cf6
Message:

Userspace printf, stdarg, and some other printf support.

Location:
libc
Files:
4 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • libc/Makefile

    rdf50cf6 r4e2cf8b  
    4242GENERIC_SOURCES = \
    4343        generic/libc.c \
    44         generic/io.c
     44        generic/io/io.c \
     45        generic/io/print.c
    4546
    4647ARCH_SOURCES += \
  • libc/arch/ia32/include/types.h

    rdf50cf6 r4e2cf8b  
    3434typedef signed int ssize_t;
    3535
     36typedef char int8_t;
     37typedef short int int16_t;
     38typedef int int32_t;
     39typedef long long int int64_t;
     40
     41typedef unsigned char uint8_t;
     42typedef unsigned short int uint16_t;
     43typedef unsigned int uint32_t;
     44typedef unsigned long long int uint64_t;
     45
    3646#endif
  • libc/generic/io/io.c

    rdf50cf6 r4e2cf8b  
    3030#include <unistd.h>
    3131#include <stdio.h>
     32#include <io/io.h>
    3233
    3334static char nl = '\n';
     
    4647}
    4748
     49/** Put count chars from buffer to stdout without adding newline
     50 * @param buf Buffer with size at least count bytes
     51 * @param count
     52 * @return 0 on succes, EOF on fail
     53 */
     54int putnchars(const char * buf, size_t count)
     55{
     56        if (write(1, (void * ) buf, count) == count) {
     57                        return 0;
     58        }
     59       
     60        return EOF;
     61}
     62
     63/** Same as puts, but does not print newline at end
     64 *
     65 */
     66int putstr(const char * str)
     67{
     68        size_t count;
     69       
     70        for (count = 0; str[count] != 0; count++);
     71        if (write(1, (void * ) str, count) == count) {
     72                        return 0;
     73        }
     74       
     75        return EOF;
     76}
     77
    4878ssize_t write(int fd, const void * buf, size_t count)
    4979{
    5080        return (ssize_t) __SYSCALL3(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count);
    5181}
     82
     83
  • libc/include/stdio.h

    rdf50cf6 r4e2cf8b  
    3232#include <types.h>
    3333
    34 #define EOF -1
     34#define EOF (-1)
    3535
    3636extern int puts(const char * str);
    3737
     38extern int printf(const char *fmt, ...);
     39
    3840#endif
Note: See TracChangeset for help on using the changeset viewer.