Last change
on this file since 268 was
259,
checked in by devigne, 11 years ago
|
giet_fat32/fat32.c :
Added _fat_write function. At the moment it does not support the creation of a
new file (the writing must exist in the disk image) and does not support the
allocation of additional cluster from the original file.
create_dmg :
Bug fix for support Linux (The tree files were not consistent with the
pathnames in boot.c).
giet_libs/stdlib.c and stdlib.h :
Added stdlib file. At the moment they only contain the atoi function.
giet_libs/stdio.h :
Bug fix in SYSCALL DEFINE. SYSCALL_FAT_READ, WRITE, CLOSE, LSEEK had the same
value.
Makefile :
Added compilation line for stdlib.o
|
File size:
1.2 KB
|
Rev | Line | |
---|
[259] | 1 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File : stdlib.c |
---|
| 3 | // Date : 05/12/2013 |
---|
| 4 | // Author : Clément DEVIGNE |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
| 6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 7 | |
---|
| 8 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 9 | // int atoi ( char * str ) |
---|
| 10 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 11 | |
---|
| 12 | int atoi(char *str) |
---|
| 13 | { |
---|
| 14 | int res = 0; // Initialize result |
---|
| 15 | int sign = 1; // Initialize sign as positive |
---|
| 16 | int i = 0; // Initialize index of first digit |
---|
| 17 | |
---|
| 18 | if (str[0] == '-') //If number is negative, then update sign |
---|
| 19 | { |
---|
| 20 | sign = -1; |
---|
| 21 | i++; // Also update index of first digit |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | for (; str[i] != '\0'; ++i) // Iterate through all digits and update the result |
---|
| 25 | { |
---|
| 26 | res = res*10 + str[i] - '0'; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | // Return result with sign |
---|
| 30 | return sign*res; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | // Local Variables: |
---|
| 34 | // tab-width: 4 |
---|
| 35 | // c-basic-offset: 4 |
---|
| 36 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 37 | // indent-tabs-mode: nil |
---|
| 38 | // End: |
---|
| 39 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
Note: See
TracBrowser
for help on using the repository browser.