├── .github
└── images
│ ├── gdisk_create.png
│ └── gdisk_list.png
├── LICENSE
├── Makefile
├── PATCH.sh
├── README.md
├── alloc.c
├── debug.c
├── debug.h
├── debug_linux.c
├── dynamic_cast.c
├── efi_main.cc
├── elf-x86_64.lds
├── initfini.c
├── io.c
├── libmy
├── C-ctype.c
├── C-translit.h
├── C_name.c
├── Makefile
├── README
├── abs.c
├── arc4random.c
├── bindtextdomain.c
├── btowc.c
├── categories.def
├── converter.c
├── converter.h
├── ctype-info.c
├── ctype.h
├── ctype_get_mb_cur_max.c
├── dgettext.c
├── dietfeatures.h
├── dietstdio.h
├── dietstring.h
├── dietwarning.h
├── dl_find_object.c
├── dl_iterate_phdr.c
├── duplocale.c
├── errno.c
├── fclose.c
├── fdopen.c
├── fflush.c
├── fgetc.c
├── fgets.c
├── fgetwc.c
├── fileno.c
├── fopen.c
├── fputc.c
├── fputs.c
├── fputwc.c
├── fread.c
├── freelocale.c
├── fseeko64.c
├── ftello64.c
├── fwrite.c
├── getentropy.c
├── gettext.c
├── gettimeofday.c
├── global-locale.c
├── iconv.c
├── iconv_close.c
├── iconv_open.c
├── iswctype.c
├── lc-ctype.c
├── libc-tsd.h
├── libmy.h
├── lltostr.c
├── locale.h
├── localeinfo.h
├── ltostr.c
├── mbrtowc.c
├── mbsnrtowcs.c
├── mbsrtowcs.c
├── memchr.c
├── memcmp.c
├── memcpy.c
├── memmove.c
├── memset.c
├── newlocale.c
├── nl_langinfo.c
├── printf.c
├── printf_chk.c
├── pthread_mutex.c
├── read_chk.c
├── setlocale.c
├── setvbuf.c
├── single_threaded.c
├── sleep.c
├── sprintf.c
├── sprintf_chk.c
├── sscanf.c
├── stdio.c
├── strcmp.c
├── strcoll.c
├── strcpy.c
├── strdup.c
├── strerror.c
├── strftime_l.c
├── strlen.c
├── strtod.c
├── strtof.c
├── strtol.c
├── strtold.c
├── strtoul.c
├── strxfrm.c
├── syscall.c
├── textdomain.c
├── tls.h
├── tolower.c
├── toupper.c
├── towlower.c
├── towupper.c
├── uselocale.c
├── v_printf.c
├── v_scanf.c
├── vfprintf.c
├── vfprintf_chk.c
├── vsnprintf.c
├── vsnprintf_chk.c
├── vsscanf.c
├── wcrtomb.c
├── wcscmp.c
├── wcscoll.c
├── wcsftime_l.c
├── wcslen.c
├── wcsnrtombs.c
├── wcsxfrm.c
├── wctob.c
├── wctype.c
├── wmemchr.c
├── wmemcmp.c
├── wmemcpy.c
├── wmemmove.c
├── wmemset.c
├── writev.c
└── xlocale.c
├── relocate-x86_64.c
├── start-ia32.S
├── start-x86_64.S
├── thread.c
├── time.c
├── uefi.h
└── uuid.c
/.github/images/gdisk_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpz4085/UEFI-GPT-fdisk/84272f87d0ef3740529af4dd702a16e406cec504/.github/images/gdisk_create.png
--------------------------------------------------------------------------------
/.github/images/gdisk_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpz4085/UEFI-GPT-fdisk/84272f87d0ef3740529af4dd702a16e406cec504/.github/images/gdisk_list.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UEFI-GPT-fdisk
2 |
3 | This is a port of the linux disk partitioning tool by Roderick W. Smith for use in a UEFI environment. It can be added as an option to the firmware boot menu like an operating system or run as an application from the UEFI Shell. When running from the shell it will accept all valid command line arguments including a block device. If run without arguments or as a firmware boot option the program will display a list of internal disks for selection. The original library can be found on SourceForge at [UEFI GPT fdisk](https://sourceforge.net/projects/uefigptfdisk/) by bub75.
4 |
5 |
6 |
7 |
8 |
9 |
10 | Example 1: Create three new partitions then write to the block device.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | Example 2: List partitions on the specified block device.
19 |
20 |
21 | ## Requirements
22 |
23 | Download from Releases or clone the repository.
24 | ```
25 | git clone https://github.com/jpz4085/UEFI-GPT-fdisk.git
26 | ```
27 | Download or clone the current [GNU-EFI](https://github.com/ncroxon/gnu-efi) library.
28 | ```
29 | git clone https://github.com/ncroxon/gnu-efi.git
30 | ```
31 | Download the source code for a gdisk [release](https://sourceforge.net/projects/gptfdisk/files/gptfdisk/) or clone the repository.
32 | ```
33 | git clone https://git.code.sf.net/p/gptfdisk/code gptfdisk-code
34 | ```
35 |
36 | ## Build Instructions
37 |
38 | 1. Install any dependencies for building gdisk: see it's README.
39 | 2. Extract the gdisk source files to a temporary location.
40 | 3. Move the GNU-EFI folder inside the UEFI-GPT-fdisk folder.
41 | 4. Move the UEFI-GPT-fdisk folder inside the gdisk source folder.
42 | 5. Now open a terminal at the UEFI-GPT-fdisk subdirectory.
43 | 6. Run "PATCH.sh" when using GPT fdisk v1.0.5 and above.
44 | 7. Enter "make" at the prompt to build the executable.
45 |
46 | ## Addendum
47 |
48 | The only functions not available are the commands to save or load the partition layout to disk. This may be addressed in a future release. Apart from that all features should operate as expected. Refer to the GPT fdisk manual or [tutorial](http://www.rodsbooks.com/gdisk/) for more information on how to use the program. Additional information about source code used in this project is provided below.
49 |
50 | - We link against "libstdc++" however this was compiled with option _GLIBCXX_USE_WCHAR_T under Ubuntu which adds a lot of useless bloat to the program. But only a full rewrite of GPT fdisk in plain C could alleviate this.
51 | - A private "libc" library called "libmy.a" is built in the "libmy" subdirectory and is mostly built from bits imported from "dietlibc" but contains some code imported from "glibc" since GNU libstdc++ also calls __newlocale().
52 | - EFI is UTF-16 while GPT fdisk uses UTF-8 internally and the original glue functions hand code conversions from UTF-8 to UTF-16. This process has been extended with Davipb's [UTF-8/UTF-16 converter](https://github.com/Davipb/utf8-utf16-converter) when processing command line arguments.
53 | - No C++ exception is handled here. The stack unwinding is tricky to implement and fortunately GPT fdisk does not use exceptions at all.
54 | - For all the system calls from the standard libray we build EFI versions of functions like write(), read() and so on, all these functions are in the ".c" source files in this "." directory, not in the "libmy" subdirectory.
55 | - We have added a "dynamic_cast.c" module that doesn't check anything because the code should be fully debugged for all use cases and using libstdc++ doesn't work the way it should (remember we don't do C++ exceptions here, so throwing a "bad_cast" would crash the program with no explanation).
56 | - The current build environment supports GCC-12 and glibc v2.39 running under Ubuntu 24.04 LTS with GPT fdisk versions up to 1.0.10. When building under other Linux distributions check your environment for compatibility.
57 |
--------------------------------------------------------------------------------
/alloc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Fonctions d'allocation mémoire, libération et réallocation.
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "uefi.h"
24 | #include "debug.h"
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 |
33 | /**
34 | * Alloue un nouveau bloc de mémoire.
35 | * @param count Le nombre d'octets à allouer.
36 | * @return L'adresse de début du bloc ou NULL en cas d'impossibilité.
37 | */
38 | void * malloc( count )
39 | size_t count ;
40 | {
41 | size_t s ;
42 | EFI_STATUS status ;
43 | size_t * q ;
44 | /* debug */
45 | UEFI_dprintf( D_POOL , "--> malloc(%u) " , (unsigned) count ) ;
46 | /* pour enregistrer la taille du bloc juste avant le bloc */
47 | s = count + sizeof( size_t ) ;
48 | /* appelle UEFI pour obtenir un bloc */
49 | status = UEFI_call( ST-> BootServices-> AllocatePool , EfiLoaderData ,
50 | s , & q ) ;
51 | /* vérifie que tout s'est bien passé */
52 | if ( EFI_ERROR( status ) ) {
53 | /* aie ! que faire ? */
54 | errno = ENOMEM ;
55 | /* affiche un message */
56 | UEFI_dprintf( D_ERROR , "**ERROR** malloc(%u) status=%d\n" ,
57 | (unsigned) count , (int) ( status & 0x7fffffff ) ) ;
58 | /* et retourne NULL, mais un plantage est proche */
59 | return NULL ;
60 | }
61 | /* debug */
62 | UEFI_dprintf( D_POOL , "addr=%p\n" , q ) ;
63 | /* enregistre la taille du bloc juste avant */
64 | q[ 0 ] = count ;
65 | /* le bloc retourné commence juste après */
66 | q ++ ;
67 | /* debug */
68 | UEFI_dprintf( D_POOL , "<-- malloc() : %p\n" , q ) ;
69 | /* retourne le pointeur incrémenté */
70 | return (void *) q ;
71 | }
72 |
73 | /**
74 | * Libère un bloc alloué.
75 | * @param block L'adresse de début du bloc à libérer.
76 | */
77 | void free( block )
78 | void * block ;
79 | {
80 | size_t * q ;
81 | EFI_STATUS status ;
82 | /* debug */
83 | UEFI_dprintf( D_POOL , "--> free(%p) " , block ) ;
84 | /* l'adresse passée à UEFI */
85 | q = (size_t *) block ;
86 | q -- ;
87 | status = UEFI_call( ST-> BootServices-> FreePool , q ) ;
88 | if ( EFI_ERROR( status ) ) {
89 | /* aie ! */
90 | UEFI_dprintf( D_ERROR ,
91 | "**ERROR** free(%p) size=%ld status=%d\n" ,
92 | block , q[ 0 ] , (int) ( status & 0x7fffffff ) ) ;
93 | /* TODO: there is a bug in the code: then what ? */
94 | }
95 | /* debug */
96 | UEFI_dprintf( D_POOL , "\n<-- free()\n" ) ;
97 | }
98 |
99 | /**
100 | * Réalloue un bloc de mémoire.
101 | * @param block L'adresse de début du bloc.
102 | * @param count La nouvelle taille.
103 | * @return L'adresse de début du bloc ou NULL en cas d'impossibilité.
104 | */
105 | void * realloc( block , count )
106 | void * block ;
107 | size_t count ;
108 | {
109 | void * p ;
110 | /* alloue toujours un nouveau bloc */
111 | p = malloc( count ) ;
112 | /* vérifie que tout s'est bien passé */
113 | if ( p == NULL ) {
114 | /* retourne NULL, errno est positionné */
115 | return NULL ;
116 | }
117 | if ( block ) {
118 | size_t * q ;
119 | size_t s ;
120 | /* l'adresse du bloc actuel */
121 | q = (size_t *) block ;
122 | /* la taille du bloc actuel */
123 | s = q[ -1 ] ;
124 | /* copie le plus petit des deux */
125 | if ( count > s ) count = s ;
126 | memcpy( p , block , count ) ;
127 | /* libère l'ancien bloc */
128 | free( block ) ;
129 | }
130 | /* l'adresse de début du nouveau bloc si tout est bon */
131 | return p ;
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/debug.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Affichage de messages pour le déverminage.
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "uefi.h"
24 | #include "debug.h"
25 | #include
26 | #include
27 | #include
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 |
35 | #ifdef EFI_DEBUG
36 |
37 |
38 | /**
39 | * Le masque de debug actuel.
40 | * Tous les bits ne sont pas utilisés ici donc la valeur -1 indique que ce
41 | * module n'a pas encore été initialisé.
42 | * De plus cela forcera l'appel à la fonction uefi_debug_mask() lors du
43 | * premier emploi de la macro UEFI_dprintf().
44 | */
45 | unsigned UEFI_debug_mask = (unsigned) -1 ;
46 |
47 |
48 | /*
49 | * Récupère la valeur de la variable globale UEFI EFIDebug.
50 | * Ce code n'utilise pas la variable globale EFIDebug exportée par GNU EFI
51 | * car il a besoin de la valeur bien avant l'appel à InitializeLib().
52 | */
53 | static void get_EFIDebug()
54 | {
55 | static const char varname[] = { 'E' , 0 , 'F' , 0 , 'I' , 0 ,
56 | 'D' , 0 , 'e' , 0 , 'b' , 0 , 'u' , 0 , 'g' , 0 , 0 , 0 } ;
57 | EFI_STATUS status ;
58 | UINT32 attribs ;
59 | UINTN size ;
60 | UINTN efidebug ;
61 | size = sizeof( efidebug ) ;
62 | status = UEFI_call( ST-> RuntimeServices-> GetVariable , varname ,
63 | & EfiGlobalVariable , & attribs , & size , & efidebug ) ;
64 | if ( status == EFI_SUCCESS ) {
65 | UEFI_debug_mask = efidebug ;
66 | } else if ( status != EFI_UNSUPPORTED ) {
67 | /* cas spécial pour la version Linux */
68 | UEFI_debug_mask = 0 ;
69 | }
70 | }
71 |
72 |
73 | /*
74 | * Contrôle le masque passé avec le masque de debug actuel.
75 | * Retourne vrai uniquement si tous les bits du masque passé sont
76 | * présents dans le masque.
77 | */
78 | int uefi_debug_mask( mask )
79 | unsigned mask ;
80 | {
81 | /* la valeur est -1 au tout premier appel */
82 | if ( UEFI_debug_mask == (unsigned) -1 ) {
83 | /* recupère la variable */
84 | get_EFIDebug() ;
85 | /* initialize */
86 | if ( UEFI_debug_mask & D_DEBUG ) UEFI_debug_mask |= D_INFO ;
87 | if ( UEFI_debug_mask & D_INFO ) UEFI_debug_mask |= D_WARN ;
88 | if ( UEFI_debug_mask & D_WARN ) UEFI_debug_mask |= D_ERROR ;
89 | if ( ! ( UEFI_debug_mask & D_ERROR ) ) UEFI_debug_mask = 0 ;
90 | /* chargement du code ça va */
91 | UEFI_debug_mask &= ~D_INIT ;
92 | /* malloc et free ça va */
93 | UEFI_debug_mask &= ~D_POOL ;
94 | }
95 | /* la macro a contrôlé qu'un bit au moins est présent
96 | il reste à contrôler que le niveau est le bon */
97 | return ( UEFI_debug_mask | mask ) == UEFI_debug_mask ;
98 | }
99 |
100 |
101 | /*
102 | * Écrit un décimal sans signe sur la console.
103 | */
104 | static void uefi_dprint_uint( v )
105 | uint64_t v ;
106 | {
107 | /* le plus grand uint64_t est 18_446_744_073_709_551_615 de 20
108 | caractères de long, on met les chiffres en commençant par le
109 | dernier dans un buffer terminé par un \0 */
110 | char out[ 21 ] ;
111 | size_t p = sizeof( out ) ;
112 | out[ -- p ] = '\0' ;
113 | while ( v ) {
114 | int val = '0' + ( v % 10 ) ;
115 | out[ -- p ] = val ;
116 | v /= 10 ;
117 | }
118 | uefi_dprint_str( out + p ) ;
119 | }
120 |
121 |
122 | /**
123 | * Compteur du nombre de "Entre dans "
124 | */
125 | static int compt ;
126 |
127 |
128 | /**
129 | * Écrit la chaîne passée sur la console.
130 | */
131 | void uefi_dprint_str( s )
132 | const char * s ;
133 | {
134 | int l , i ;
135 | if ( s[ 0 ] == 'E' && s[ 1 ] == 'n' && s[ 2 ] == 't' && s[ 3 ] == 'r'
136 | && s[ 4 ] == 'e' && s[ 5 ] == ' ' && s[ 6 ] == 'd'
137 | && s[ 7 ] == 'a' && s[ 8 ] == 'n' && s[ 9 ] == 's'
138 | && s[ 10 ] == ' ' )
139 | {
140 | compt ++ ;
141 | uefi_dprint_uint( compt ) ;
142 | UEFI_console_putchar( ']' , 1 ) ;
143 | }
144 | /* écrit sur StdErr */
145 | l = strlen( s ) ;
146 | for ( i = 0 ; i < l ; i ++ ) {
147 | /* message de debug, ne teste pas la valeur de retour */
148 | UEFI_console_putchar( s[ i ] , 1 ) ;
149 | }
150 | }
151 |
152 |
153 | #endif /* EFI_DEBUG */
154 |
155 |
--------------------------------------------------------------------------------
/debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | * Definitions for module debug.c.
17 | *
18 | * This mainly defines the macro UEFI_dprintf() to print a debug message.
19 | * This module queries the UEFI firmware to get the value of its EFIDebug
20 | * variable and know what messages to print or not.
21 | * The debug code is only included in the program if the macro EFI_DEBUG
22 | * was defined at compile-time, the value of the EFIDebug variable is
23 | * ignored otherwise.
24 | *
25 | * The first argument is the bit mask giving the reason and optional
26 | * severity of the message. The second argument is a printf() format
27 | * string and remaining arguments are the values to be put in the
28 | * formatted string. Ex:
29 | * UEFI_dprintf( D_POOL , "--> malloc(%d)\n" , count ) ;
30 | * Of course, when the code calls this macro no side effect is allowed, no:
31 | * UEFI_dprintf( D_INIT , "%d" , x ++ ) ;
32 | * or alike!
33 | *
34 | */
35 |
36 | #ifndef debug_h_INCLUDED
37 | #define debug_h_INCLUDED
38 |
39 | #include
40 |
41 | /* This file is included from C++ source files. */
42 | #if defined( __cplusplus )
43 | extern "C" {
44 | #endif
45 |
46 | /* Bitmasks defining what to debug. Copied from GNU EFI efidebug.h */
47 | #define D_INIT 0x00000001 /* Initialization style messages */
48 | #define D_WARN 0x00000002 /* Warnings */
49 | #define D_LOAD 0x00000004 /* Load events */
50 | #define D_FS 0x00000008 /* EFI File system */
51 | #define D_POOL 0x00000010 /* Alloc & Free's */
52 | #define D_PAGE 0x00000020 /* Alloc & Free's */
53 | #define D_INFO 0x00000040 /* Verbose */
54 | #define D_VAR 0x00000100 /* Variable */
55 | #define D_PARSE 0x00000200 /* Command parsing */
56 | #define D_BM 0x00000400 /* Boot manager */
57 | #define D_BLKIO 0x00001000 /* BlkIo Driver */
58 | #define D_BLKIO_ULTRA 0x00002000 /* BlkIo Driver */
59 | #define D_TXTIN 0x00010000 /* Simple Input Driver */
60 | #define D_TXTOUT 0x00020000 /* Simple Text Output Driver */
61 | #define D_ERROR 0x80000000 /* Error */
62 |
63 | /* Special bitmask for extra debug options. */
64 | #define D_DEBUG 0x00000080 /* Verbose for debug */
65 |
66 | /* A little macro magic to be able to call all the same way:
67 | UEFI_dprintf( mask , "text" )
68 | UEFI_dprintf( mask , "text %d" , i )
69 | UEFI_dprintf( mask , "text %d %s" , i , s )
70 | and so on...
71 | */
72 |
73 | /* retourne le premier argument de ... */
74 | #define UEFI_dprintf_PREMS( ... ) UEFI_dprintf_PREMS_( __VA_ARGS__ , ignore )
75 |
76 | /* macro d'aide pour UEFI_dprintf_PREMS() */
77 | #define UEFI_dprintf_PREMS_( un , ... ) un
78 |
79 | /* retourne ", x" si ... a plus de deux argument, rien sinon */
80 | #define UEFI_dprintf_RESTE( ... ) UEFI_dprintf_RESTE_( \
81 | UEFI_dprintf_NBR( __VA_ARGS__ ) , __VA_ARGS__ )
82 |
83 | /* macro d'aide pour UEFI_dprintf_RESTE() */
84 | #define UEFI_dprintf_RESTE_( quantite , ... ) \
85 | UEFI_dprintf_RESTE__( quantite , __VA_ARGS__ )
86 |
87 | /* seconde macro d'aide pour UEFI_dprintf_RESTE() quantite est ici un mot */
88 | #define UEFI_dprintf_RESTE__( quantite , ... ) \
89 | UEFI_dprintf_RESTE_##quantite( __VA_ARGS__ )
90 |
91 | /* ignore si un seul argument */
92 | #define UEFI_dprintf_RESTE_UN( un )
93 |
94 | /* sinon insère une virgule avant le reste */
95 | #define UEFI_dprintf_RESTE_PLUS( un , ... ) , __VA_ARGS__
96 |
97 | /* retourne "UN" ou "PLUS" si ... a un ou plus d'arguments (max 15) */
98 | #define UEFI_dprintf_NBR( ... ) UEFI_dprintf_NBR16( __VA_ARGS__ , \
99 | PLUS , PLUS , PLUS , PLUS , PLUS , PLUS , PLUS , PLUS , \
100 | PLUS , PLUS , PLUS , PLUS , PLUS , PLUS , UN , ignore )
101 |
102 | /* retourne le seizième de ses (au moins) dix-sept arguments */
103 | #define UEFI_dprintf_NBR16( un , deux , trois , quatre , cinq , \
104 | six , sept , huit , neuf , dix , onze , douze , treize , \
105 | quatorze , quinze , seize , ... ) seize
106 |
107 | #ifdef EFI_DEBUG
108 |
109 | extern unsigned UEFI_debug_mask ;
110 |
111 | extern int uefi_debug_mask( unsigned ) ;
112 |
113 | /* fonction interne qui écrit la chaîne sur la console */
114 | extern void uefi_dprint_str( const char * ) ;
115 |
116 | /* Appeler snprintf() directement dans cette macro permet au compilateur
117 | de contrôler les arguments par rapport au format passé: le compilateur
118 | GNU produit un warning s'il détecte une incohérence. */
119 | #define UEFI_dprintf( mask , ... ) do { \
120 | if ( UEFI_debug_mask & ( mask ) && \
121 | uefi_debug_mask( mask ) ) \
122 | { \
123 | char text[ 1000 ] ; \
124 | sprintf( text , UEFI_dprintf_PREMS( __VA_ARGS__ ) \
125 | UEFI_dprintf_RESTE( __VA_ARGS__ ) ) ; \
126 | uefi_dprint_str( text ) ; \
127 | } \
128 | } while ( 0 )
129 |
130 | #else
131 |
132 | /* Cette version en mode non-debug sera enlevée du code par l'optimiseur
133 | mais permet de faire un contrôle de la syntaxe de l'appel. */
134 | #define UEFI_dprintf( mask , ... ) while ( 0 ) { \
135 | char text[ 1000 ] ; \
136 | sprintf( text , UEFI_dprintf_PREMS( __VA_ARGS__ ) \
137 | UEFI_dprintf_RESTE( __VA_ARGS__ ) ) ; \
138 | }
139 |
140 | #endif /* EFI_DEBUG */
141 |
142 | #if defined( __cplusplus )
143 | }
144 | #endif
145 |
146 | #endif /* debug_h_INCLUDED */
147 |
148 |
--------------------------------------------------------------------------------
/debug_linux.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en mais 2015.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Compléments pour un link correct de gdisk.
18 | * Le module debug.c emploie des fonctions qui ne sont disponibles que dans
19 | * GNU EFI ou io.c, ce module apporte les mêmes fonctionnalités pour Linux.
20 | *
21 | */
22 |
23 |
24 | /* en premier */
25 | #include "uefi.h"
26 | #include "debug.h"
27 | #include
28 | #include
29 |
30 | #include
31 |
32 |
33 | #ifdef EFI_DEBUG
34 |
35 |
36 | /**
37 | * Lit un caractère depuis la console.
38 | * @return le caractère lu (valeur unicode)
39 | * ou -1 en cas d'erreur (consulter errno)
40 | * Note : pour simplifier ce code ne gère pas tout Unicode mais seulement
41 | * la partie qui se code en un CHAR16 en UTF-16
42 | * Note : ce code est appelé par les macros de debug donc pour éviter
43 | * une récursion infinie, il n'appelle aucun code de debug.
44 | */
45 | long UEFI_console_getchar()
46 | {
47 | return getchar() ;
48 | }
49 |
50 |
51 | /**
52 | * Écrit un caractère sur la console.
53 | * @param c Le caractère Unicode à écrire.
54 | * @param e Écrire sur StdErr plutôt que ConOut.
55 | * @return Le caractère Unicode écrit convertit en int
56 | * ou -1 en cas d'erreur (consulter errno).
57 | * Note : ce code est appelé par les macros de debug donc pour éviter
58 | * une récursion infinie, il n'appelle aucun code de debug.
59 | */
60 | int UEFI_console_putchar( c , e )
61 | long c ;
62 | char e ;
63 | {
64 | FILE * f ;
65 | f = e ? stderr : stdout ;
66 | if ( fputc( c , f ) == EOF ) return -1 ;
67 | return (unsigned int) c ;
68 | }
69 |
70 |
71 | /**
72 | * Autres élémens employés dans le module debug.c.
73 | */
74 |
75 | static EFI_RUNTIME_SERVICES leRT ;
76 | EFI_RUNTIME_SERVICES * RT = & leRT ;
77 | static EFI_SYSTEM_TABLE leST = { .RuntimeServices = & leRT } ;
78 | EFI_SYSTEM_TABLE * ST = & leST ;
79 | EFI_GUID EfiGlobalVariable ;
80 | UINT64 efi_call5( f , a1 , a2 , a3 , a4 , a5 )
81 | void * f __attribute__((unused)) ;
82 | UINT64 a1 __attribute__((unused)) ;
83 | UINT64 a2 __attribute__((unused)) ;
84 | UINT64 a3 __attribute__((unused)) ;
85 | UINT64 a4 __attribute__((unused)) ;
86 | UINT64 a5 __attribute__((unused)) ;
87 | {
88 | return EFI_UNSUPPORTED ;
89 | }
90 |
91 |
92 | #endif /* EFI_DEBUG */
93 |
94 |
--------------------------------------------------------------------------------
/dynamic_cast.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /*
16 | * Dynamic cast.
17 | */
18 |
19 |
20 | /* en premier */
21 | #include "uefi.h"
22 |
23 |
24 | void * __dynamic_cast( p )
25 | void * p ;
26 | /* base class */
27 | /* destination class */
28 | {
29 | return p ;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libmy/C_name.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "localeinfo.h"
21 | #include "ctype.h"
22 | /* Define a constant for the name of the standard C locale, so the string
23 | constant is not repeated in dozens of object files. */
24 |
25 | #include "localeinfo.h"
26 |
27 | /* Name of our standard locale. */
28 | const char _nl_C_name[] = "C";
29 | const char _nl_POSIX_name[] = "POSIX";
30 |
31 | /* The standard codeset. */
32 | const char _nl_C_codeset[] = "ANSI_X3.4-1968";
33 |
--------------------------------------------------------------------------------
/libmy/Makefile:
--------------------------------------------------------------------------------
1 | ##
2 | ## This file is part of UEFI GPT fdisk.
3 | ##
4 | ## UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | ## UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | ## Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | ##
8 | ## Original work is copyleft Bernard Burette.
9 | ## Modifications are copyleft Joseph Zeller.
10 | ##
11 | ## This program is distributed under the terms of the GNU GPL version 2.
12 | ## La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | ##
14 |
15 | ##
16 | ## Makefile to build a reduced version of the libc.
17 | ## This lib is built from bits taken from "dietlibc" but also
18 | ## bits of "glic" (mostly the locale bits because "dietlibc"
19 | ## doesn't have those bits). Not tried to support wchar_t here,
20 | ## all the code we use is only UTF-8.
21 | ##
22 | ## What a mess!
23 | ##
24 |
25 | # Host/target identification
26 | ARCH ?= $(shell uname -m|sed s,i[3-9]86,ia32,)
27 | # FreeBSD (and possibly others) reports amd64 instead of x86_64
28 | ifeq ($(ARCH),amd64)
29 | override ARCH = x86_64
30 | endif
31 |
32 | # Compiler switch for 32 or 64 bits.
33 | ifeq ($(ARCH),ia32)
34 | # Build 32 bits binaries (not tested).
35 | CFLAGS += -m32 -mtune=i386
36 | endif
37 | ifeq ($(ARCH),x86_64)
38 | # Build 64 bits binaries.
39 | CFLAGS += -m64
40 | endif
41 |
42 | # UEFI firmware doesn't initialize CPU for MMX et al (returning float or double
43 | # using Linux x86_64 ABI is not possible: better break during compilation than
44 | # crash during run).
45 | CFLAGS += -mno-mmx -mno-sse
46 | # Optimize for size. We also need to use -fno-inline otherwise will
47 | # try to define atof() as "inline" returning a "float" which is not available
48 | # in UEFI using x86_64 ABI and is forbidden by -mno-mmx option.
49 | CFLAGS += -Os -fno-inline
50 | # Compile Position Independent Code and for foreign platform.
51 | CFLAGS += -fPIC -DPIC -ffreestanding
52 | # wchar_t for UEFI is 16 bits (we don't use UFT-16 here and standard libraries
53 | # were built without this flag, so using this switch could be a problem).
54 | CFLAGS += -fshort-wchar
55 | # Code should be well debugged so don't need these.
56 | CFLAGS += -fno-stack-protector -fno-stack-check -fomit-frame-pointer
57 | # ? need stack "shadow space" in UEFI.
58 | CFLAGS += -mno-red-zone
59 | # ?
60 | CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
61 | # Alloue tout l'espace de pile d'une fonction (plus rapide).
62 | CFLAGS += -maccumulate-outgoing-args
63 | # Be thorough.
64 | CFLAGS += -Wall -Wextra -Werror
65 | # Debug UEFI code flag.
66 | CFLAGS += $(EFI_DEBUG_FLAGS)
67 |
68 | # List of object files required to link a nice gdisk.so.
69 | OBJS += abs.o dl_iterate_phdr.o syscall.o sleep.o errno.o
70 | OBJS += strlen.o strcmp.o strcoll.o strxfrm.o strcpy.o strdup.o
71 | OBJS += dl_find_object.o wcslen.o wcscmp.o wcscoll.o wcsxfrm.o
72 | OBJS += memset.o memcmp.o memchr.o memcpy.o memmove.o
73 | OBJS += wmemset.o wmemcmp.o wmemchr.o wmemcpy.o wmemmove.o
74 | OBJS += mbrtowc.o mbsnrtowcs.o mbsrtowcs.o
75 | OBJS += tolower.o toupper.o towlower.o towupper.o
76 | OBJS += ltostr.o lltostr.o strtol.o strtoul.o strtof.o strtod.o strtold.o
77 | OBJS += wcrtomb.o wcsnrtombs.o
78 | OBJS += stdio.o fopen.o fdopen.o setvbuf.o fileno.o fflush.o fclose.o
79 | OBJS += fseeko64.o ftello64.o
80 | OBJS += fgetc.o fgetwc.o fgets.o fread.o
81 | OBJS += fputc.o fputwc.o fputs.o fwrite.o writev.o
82 | OBJS += printf.o sprintf.o vfprintf.o vsnprintf.o v_printf.o
83 | OBJS += printf_chk.o sprintf_chk.o vfprintf_chk.o vsnprintf_chk.o
84 | OBJS += sscanf.o vsscanf.o v_scanf.o
85 | OBJS += textdomain.o bindtextdomain.o converter.o
86 | OBJS += nl_langinfo.o global-locale.o ctype-info.o setlocale.o
87 | OBJS += xlocale.o C-ctype.o C_name.o lc-ctype.o
88 | OBJS += newlocale.o uselocale.o duplocale.o freelocale.o
89 | OBJS += strftime_l.o wcsftime_l.o strerror.o gettext.o dgettext.o
90 | OBJS += btowc.o wctob.o iswctype.o wctype.o ctype_get_mb_cur_max.o
91 | OBJS += iconv.o iconv_close.o iconv_open.o
92 | OBJS += single_threaded.o pthread_mutex.o
93 | OBJS += gettimeofday.o getentropy.o read_chk.o arc4random.o
94 |
95 |
96 | # Build the library by default.
97 | #
98 | all: libmy.a
99 |
100 |
101 | # Cleanup.
102 | #
103 | clean: #no pre-reqs
104 | -rm -f core *.o *~ libmy.a
105 |
106 |
107 | # Phony targets (build them every time).
108 | #
109 | .PHONY: all clean
110 |
111 |
112 | # The library is made of all object files.
113 | #
114 | libmy.a: $(OBJS)
115 | ar -rs $@ $?
116 | -ranlib $@
117 |
118 |
--------------------------------------------------------------------------------
/libmy/README:
--------------------------------------------------------------------------------
1 |
2 | UEFI GPT fdisk: aka gdisk.efi by Bub'soft.
3 | Build of GPT fdisk for UEFI BIOS environments.
4 | Version 0.3 april 2014.
5 | Version <1 means it's pretty much beta software like GPT fdisk in fact.
6 |
7 | First attempt by Bernard Burette january 2014.
8 |
9 | This is a reduced version of libc.so for UEFI.
10 |
11 |
12 | This library is linked to UEFI GPT fdisk in replacement for the standard C
13 | library. GPT fdisk is written in C++ and the UEFI version is linked with
14 | -lstdc++ -lgcc_eh which are the standard C++ libraries. The original code
15 | and these libraries are written in C and require functions like printf()
16 | or malloc() to work.
17 |
18 | When builing the UEFI executable we don't have Linux running so the memory
19 | services or file-system services are not available as Linux system calls.
20 | This library provides all standard C library functions down to a small list
21 | of functions implemented as mainly system calls. The list is :
22 |
23 | open64() close() read() write() fsync() ioctl() lseek64() stat64()
24 | malloc() realloc() free()
25 | atexit() exit() abort()
26 | time()
27 |
28 | A few things to know:
29 | - Any 32 bits stuff has *not* been tested (but is it still necessary nowadays?)
30 | the GNU EFI library can be compiled in both 32 bits and 64 bits but not
31 | the UEFI GPT fdisk.
32 | - For all the system calls from the standard libray we build EFI versions
33 | of write(), read() and so on, all these functions are in the ".c" source
34 | files in the parent directory, not in this subdirectory.
35 |
36 |
--------------------------------------------------------------------------------
/libmy/abs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int abs( j )
21 | int j ;
22 | {
23 | /* TODO: ne marche pas pour MIN_INT */
24 | if ( j < 0 ) return - j ;
25 | return j ;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/arc4random.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | uint32_t arc4random(void)
22 | {
23 | __fortify_fail( "arc4random()" ) ;
24 | }
25 |
--------------------------------------------------------------------------------
/libmy/bindtextdomain.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | char * bindtextdomain( domainname , dirname )
21 | const char * domainname __attribute__((unused)) ;
22 | const char * dirname __attribute__((unused)) ;
23 | {
24 | /* TODO: ? */
25 | __fortify_fail( "bindtextdomain()" ) ;
26 | /*
27 | return NULL ;
28 | */
29 | }
30 |
31 | __typeof( bindtextdomain ) bind_textdomain_codeset __attribute__(( weak , alias( "bindtextdomain" ) )) ;
32 |
33 |
--------------------------------------------------------------------------------
/libmy/btowc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | wint_t btowc( c )
21 | int c ;
22 | {
23 | if ( ( c & ( ~ 0x7f ) ) == 0 ) return (wint_t) c ;
24 | return WEOF ;
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/libmy/converter.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2019 Davipb
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
4 | * software and associated documentation files (the "Software"), to deal in the Software
5 | * without restriction, including without limitation the rights to use, copy, modify,
6 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | * permit persons to whom the Software is furnished to do so, subject to the following
8 | * conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all copies
11 | * or substantial portions of the Software.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
18 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 | *
20 | */
21 |
22 | #pragma once
23 | #include
24 | #include
25 |
26 |
27 | typedef uint8_t utf8_t; // The type of a single UTF-8 character
28 | typedef uint16_t utf16_t; // The type of a single UTF-16 character
29 |
30 | /*
31 | * Converts a UTF-16 string to a UTF-8 string.
32 | *
33 | * utf16:
34 | * The UTF-16 string, not null-terminated.
35 | *
36 | * utf16_len:
37 | * The length of the UTF-16 string, in 16-bit characters.
38 | *
39 | * utf8:
40 | * The buffer where the resulting UTF-8 string will be stored.
41 | * If set to NULL, indicates that the function should just calculate
42 | * the required buffer size and not actually perform any conversions.
43 | *
44 | * utf8_len:
45 | * The length of the UTF-8 buffer, in 8-bit characters.
46 | * Ignored if utf8 is NULL.
47 | *
48 | * return:
49 | * If utf8 is NULL, the size of the required UTF-8 buffer.
50 | * Otherwise, the number of characters written to the utf8 buffer.
51 | *
52 | */
53 | size_t utf16_to_utf8(
54 | utf16_t const* utf16, size_t utf16_len,
55 | utf8_t* utf8, size_t utf8_len
56 | );
57 |
58 | /*
59 | * Converts a UTF-8 string to a UTF-16 string.
60 | *
61 | * utf8:
62 | * The UTF-8 string, not null-terminated.
63 | *
64 | * utf8_len:
65 | * The length of the UTF-8 string, in 8-bit characters.
66 | *
67 | * utf16:
68 | * The buffer where the resulting UTF-16 string will be stored.
69 | * If set to NULL, indicates that the function should just calculate
70 | * the required buffer size and not actually perform any conversions.
71 | *
72 | * utf16_len:
73 | * The length of the UTF-16 buffer, in 16-bit characters.
74 | * Ignored if utf16 is NULL.
75 | *
76 | * return:
77 | * If utf16 is NULL, the size of the required UTF-16 buffer,
78 | * in 16-bit characters.
79 | * Otherwise, the number of characters written to the utf8 buffer, in
80 | * 16-bit characters.
81 | *
82 | */
83 | size_t utf8_to_utf16(
84 | utf8_t const* utf8, size_t utf8_len,
85 | utf16_t* utf16, size_t utf16_len
86 | );
87 |
--------------------------------------------------------------------------------
/libmy/ctype-info.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "localeinfo.h"
21 | /* Copyright (C) 1991-2013 Free Software Foundation, Inc.
22 | This file is part of the GNU C Library.
23 |
24 | The GNU C Library is free software; you can redistribute it and/or
25 | modify it under the terms of the GNU Lesser General Public
26 | License as published by the Free Software Foundation; either
27 | version 2.1 of the License, or (at your option) any later version.
28 |
29 | The GNU C Library is distributed in the hope that it will be useful,
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 | Lesser General Public License for more details.
33 |
34 | You should have received a copy of the GNU Lesser General Public
35 | License along with the GNU C Library; if not, see
36 | . */
37 |
38 | #define CTYPE_EXTERN_INLINE /* Define real functions for accessors. */
39 | #include "ctype.h"
40 | #include
41 | #include "localeinfo.h"
42 |
43 | __libc_tsd_define (, const uint16_t *, CTYPE_B)
44 | __libc_tsd_define (, const int32_t *, CTYPE_TOLOWER)
45 | __libc_tsd_define (, const int32_t *, CTYPE_TOUPPER)
46 |
47 |
48 | void
49 | __ctype_init (void)
50 | {
51 | const uint16_t **bp = __libc_tsd_address (const uint16_t *, CTYPE_B);
52 | *bp = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
53 | const int32_t **up = __libc_tsd_address (const int32_t *, CTYPE_TOUPPER);
54 | *up = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
55 | const int32_t **lp = __libc_tsd_address (const int32_t *, CTYPE_TOLOWER);
56 | *lp = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
57 | }
58 | libc_hidden_def (__ctype_init)
59 |
60 |
61 | /* #include */
62 | /* #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) */
63 |
64 | #if 1
65 |
66 | /* Defined in locale/C-ctype.c. */
67 | extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
68 | extern const char _nl_C_LC_CTYPE_class32[] attribute_hidden;
69 | extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
70 | extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
71 | extern const char _nl_C_LC_CTYPE_class_upper[] attribute_hidden;
72 | extern const char _nl_C_LC_CTYPE_class_lower[] attribute_hidden;
73 | extern const char _nl_C_LC_CTYPE_class_alpha[] attribute_hidden;
74 | extern const char _nl_C_LC_CTYPE_class_digit[] attribute_hidden;
75 | extern const char _nl_C_LC_CTYPE_class_xdigit[] attribute_hidden;
76 | extern const char _nl_C_LC_CTYPE_class_space[] attribute_hidden;
77 | extern const char _nl_C_LC_CTYPE_class_print[] attribute_hidden;
78 | extern const char _nl_C_LC_CTYPE_class_graph[] attribute_hidden;
79 | extern const char _nl_C_LC_CTYPE_class_blank[] attribute_hidden;
80 | extern const char _nl_C_LC_CTYPE_class_cntrl[] attribute_hidden;
81 | extern const char _nl_C_LC_CTYPE_class_punct[] attribute_hidden;
82 | extern const char _nl_C_LC_CTYPE_class_alnum[] attribute_hidden;
83 |
84 | #define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
85 |
86 | const unsigned short int *__ctype_b = b (unsigned short int, class, 128);
87 | const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0);
88 | const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
89 | const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
90 | const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
91 | const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
92 |
93 | compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
94 | compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
95 | compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
96 | compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
97 | compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
98 | compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/libmy/ctype.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #ifndef _CTYPE_H
19 |
20 | #ifndef _ISOMAC
21 | /* Initialize ctype locale data. */
22 | extern void __ctype_init (void);
23 | libc_hidden_proto (__ctype_init)
24 |
25 | extern int __isctype (int __c, int __mask);
26 |
27 | # ifndef NOT_IN_libc
28 |
29 | /* These accessors are used by the optimized macros to find the
30 | thread-local cache of ctype information from the current thread's
31 | locale. For inside libc, define them as inlines using the _NL_CURRENT
32 | accessors. We don't use _NL_CURRENT_LOCALE->__ctype_b here because we
33 | want to cause a link-time ref to _nl_current_LC_CTYPE under
34 | NL_CURRENT_INDIRECT. */
35 |
36 | # include "localeinfo.h"
37 | # include "libc-tsd.h"
38 |
39 | # ifndef CTYPE_EXTERN_INLINE /* Used by ctype/ctype-info.c, which see. */
40 | # define CTYPE_EXTERN_INLINE extern inline
41 | # endif
42 |
43 | __libc_tsd_define (extern, const uint16_t *, CTYPE_B)
44 | __libc_tsd_define (extern, const int32_t *, CTYPE_TOUPPER)
45 | __libc_tsd_define (extern, const int32_t *, CTYPE_TOLOWER)
46 |
47 |
48 | static inline const uint16_t ** __attribute__(( const ))
49 | __ctype_b_loc (void)
50 | {
51 | return __libc_tsd_address (const uint16_t *, CTYPE_B);
52 | }
53 |
54 | static inline const int32_t ** __attribute__(( const ))
55 | __ctype_toupper_loc (void)
56 | {
57 | return __libc_tsd_address (const int32_t *, CTYPE_TOUPPER);
58 | }
59 |
60 | static inline const int32_t ** __attribute__(( const ))
61 | __ctype_tolower_loc (void)
62 | {
63 | return __libc_tsd_address (const int32_t *, CTYPE_TOLOWER);
64 | }
65 |
66 | # endif /* Not NOT_IN_libc. */
67 | #endif
68 |
69 | #include
70 |
71 | #ifndef _ISOMAC
72 | # if !defined __NO_CTYPE && !defined NOT_IN_libc
73 | /* The spec says that isdigit must only match the decimal digits. We
74 | can check this without a memory access. */
75 | # undef isdigit
76 | # define isdigit(c) ({ int __c = (c); __c >= '0' && __c <= '9'; })
77 | # undef isdigit_l
78 | # define isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; })
79 | # undef __isdigit_l
80 | # define __isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; })
81 | # endif
82 | #endif
83 |
84 | #endif /* ctype.h */
85 |
--------------------------------------------------------------------------------
/libmy/ctype_get_mb_cur_max.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t __ctype_get_mb_cur_max()
21 | {
22 | return sizeof( wchar_t ) ;
23 | }
24 |
25 | __typeof( __ctype_get_mb_cur_max ) ctype_get_mb_cur_max __attribute__((weak,alias("__ctype_get_mb_cur_max"))) ;
26 |
27 |
--------------------------------------------------------------------------------
/libmy/dgettext.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en novembre 2015.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #undef dgettext
21 | char* dgettext( domainname , msgid )
22 | const char * domainname __attribute__(( unused )) ;
23 | const char * msgid ;
24 | {
25 | return (char*) msgid ;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/dietstdio.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* diet stdio */
19 |
20 | #include
21 | #include
22 | #include "dietfeatures.h"
23 | #ifdef WANT_THREAD_SAFE
24 | #include
25 | #endif
26 | #include
27 |
28 | #ifdef WANT_SMALL_STDIO_BUFS
29 | #define BUFSIZE 128
30 | #else
31 | #define BUFSIZE 2048
32 | #endif
33 |
34 | struct __stdio_file {
35 | int fd;
36 | int flags;
37 | uint32_t bs; /* read: bytes in buffer */
38 | uint32_t bm; /* position in buffer */
39 | uint32_t buflen; /* length of buf */
40 | char *buf;
41 | struct __stdio_file *next; /* for fflush */
42 | pid_t popen_kludge;
43 | unsigned char ungetbuf;
44 | char ungotten;
45 | #ifdef WANT_THREAD_SAFE
46 | pthread_mutex_t m;
47 | #endif
48 | };
49 |
50 | #define ERRORINDICATOR 1
51 | #define EOFINDICATOR 2
52 | #define BUFINPUT 4
53 | #define BUFLINEWISE 8
54 | #define NOBUF 16
55 | #define STATICBUF 32
56 | #define FDPIPE 64
57 | #define CANREAD 128
58 | #define CANWRITE 256
59 | #define CHECKLINEWISE 512
60 |
61 | #define _IONBF 2
62 | #define _IOLBF 1
63 | #define _IOFBF 0
64 |
65 | /* #include */
66 |
67 | /* internal function to flush buffer.
68 | * However, if next is BUFINPUT and the buffer is an input buffer, it
69 | * will not be flushed. Vice versa for output */
70 | /* extern int __fflush4(FILE *stream,int next); */
71 | extern int __buffered_outs(const char *s,size_t len);
72 |
73 | /* ..scanf */
74 | struct arg_scanf {
75 | void *data;
76 | int (*getch)(void*);
77 | int (*putch)(int,void*);
78 | };
79 |
80 | int __v_scanf(struct arg_scanf* fn, const char *format, va_list arg_ptr);
81 |
82 | struct arg_printf {
83 | void *data;
84 | int (*put)(void*,size_t,void*);
85 | };
86 |
87 | int __v_printf(struct arg_printf* fn, const char *format, va_list arg_ptr);
88 |
89 | /* extern FILE *__stdio_root; */
90 |
91 | int __fflush_stdin(void);
92 | int __fflush_stdout(void);
93 | int __fflush_stderr(void);
94 |
95 | /* FILE* __stdio_init_file(int fd,int closeonerror,int mode); */
96 | int __stdio_parse_mode(const char *mode) __attribute__((__pure__));
97 | void __stdio_flushall(void);
98 |
99 | #ifndef __THREAD_INTERNAL_H__
100 | int __libc_close(int fd);
101 | int __libc_open(const char*fn,int flags,...);
102 | ssize_t __libc_read(int fd,void*buf,size_t len);
103 | ssize_t __libc_write(int fd,const void*buf,size_t len);
104 | #endif
105 |
106 | /* FILE *fopen_unlocked(const char *path, const char *mode) __THROW; */
107 | /* FILE *fdopen_unlocked(int fildes, const char *mode) __THROW; */
108 | /* FILE *freopen_unlocked(const char *path, const char *mode, FILE *stream) __THROW; */
109 |
110 | int __stdout_is_tty(void);
111 | int __stdin_is_tty(void);
112 |
113 | /* Bernard added a few more */
114 |
115 | extern int __vfprintf_chk( FILE * __stream , int __flag ,
116 | const char * __format , __gnuc_va_list __ap ) ;
117 |
118 | extern int __vsnprintf_chk( char * __s , size_t __n , int __flag ,
119 | size_t __slen , const char * __format ,
120 | __gnuc_va_list __ap ) ;
121 |
122 |
--------------------------------------------------------------------------------
/libmy/dietstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #ifndef _DIET_STRING_H_
19 | #define _DIET_STRING_H_
20 |
21 | #include
22 |
23 | #if __WORDSIZE == 64
24 | # define MKW(x) (x|x<<8|x<<16|x<<24|x<<32|x<<40|x<<48|x<<56)
25 | # define STRALIGN(x) (((unsigned long)x&7)?8-((unsigned long)x&7):0)
26 | #else /* __WORDSIZE == 32 */
27 | # define MKW(x) (x|x<<8|x<<16|x<<24)
28 | # define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
29 | #endif
30 |
31 | /* GFC(x) - returns first character */
32 | /* INCSTR(x) - moves to next character */
33 | #if __BYTE_ORDER == __LITTLE_ENDIAN
34 | # define GFC(x) ((x)&0xff)
35 | # define INCSTR(x) do { x >>= 8; } while (0)
36 | #else
37 | # define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
38 | # define INCSTR(x) do { x <<= 8; } while (0)
39 | #endif
40 |
41 | #define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
42 |
43 | #endif /* _DIET_STRING_H_ */
44 |
--------------------------------------------------------------------------------
/libmy/dietwarning.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "dietfeatures.h"
19 |
20 | #ifdef WANT_LINKER_WARNINGS
21 |
22 | #ifndef __ASSEMBLER__
23 |
24 | #define link_warning(symbol,msg) \
25 | asm (".section .gnu.warning." symbol "\n\t.string \"" msg "\"\n\t.previous");
26 |
27 | #else
28 |
29 | #define link_warning(symbol,msg) \
30 | .section .gnu.warning.##symbol ;\
31 | .string msg ;\
32 | .previous
33 |
34 | #endif
35 |
36 | #else
37 |
38 | #define link_warning(foo,bar)
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/libmy/dl_find_object.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int __attribute__((weak)) _dl_find_object (pc1, result)
21 | void *pc1 __attribute__((unused)) ;
22 | struct dl_find_object *result __attribute__((unused)) ;
23 | {
24 | __fortify_fail( "_dl_find_object()" ) ;
25 | }
26 |
--------------------------------------------------------------------------------
/libmy/dl_iterate_phdr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* support function when linking against libgcc_eh.a
19 | *
20 | * see gcc sources _Unwind_Find_FDE() in unwind-dw2-fde-glibc.c
21 | *
22 | * Copyright (C) 2005 Markus F.X.J. Oberhumer
23 | * License: GNU GPL
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #if __WORDSIZE == 64
32 | # define ElfW(type) Elf64_##type
33 | #else
34 | # define ElfW(type) Elf32_##type
35 | #endif
36 |
37 | struct dl_phdr_info
38 | {
39 | ElfW(Addr) dlpi_addr;
40 | const char *dlpi_name;
41 | const ElfW(Phdr) *dlpi_phdr;
42 | ElfW(Half) dlpi_phnum;
43 | };
44 |
45 |
46 | /* dl_support.c defines these and initializes them early on. */
47 | /*
48 | extern ElfW(Phdr) *_dl_phdr;
49 | extern size_t _dl_phnum;
50 | */
51 |
52 |
53 | int dl_iterate_phdr(int (*callback) (struct dl_phdr_info *info, size_t size, void *data),
54 | void *data);
55 | int dl_iterate_phdr(int (*callback) (struct dl_phdr_info *info, size_t size, void *data) __attribute((unused)) ,
56 | void *data __attribute((unused)) )
57 | {
58 | /*
59 | int ret;
60 | struct dl_phdr_info info;
61 |
62 | if (_dl_phnum != 0)
63 | {
64 | */
65 | /* This entry describes this statically-linked program itself. */
66 | /*
67 | info.dlpi_addr = 0;
68 | info.dlpi_name = "";
69 | info.dlpi_phdr = _dl_phdr;
70 | info.dlpi_phnum = _dl_phnum;
71 | ret = (*callback) (&info, sizeof(info), data);
72 | if (ret != 0)
73 | return ret;
74 | }
75 | */
76 | return 0;
77 | }
78 |
79 |
80 |
--------------------------------------------------------------------------------
/libmy/duplocale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "ctype.h"
21 | /* Duplicate handle for selection of locales.
22 | Copyright (C) 1997-2013 Free Software Foundation, Inc.
23 | This file is part of the GNU C Library.
24 | Contributed by Ulrich Drepper , 1997.
25 |
26 | The GNU C Library is free software; you can redistribute it and/or
27 | modify it under the terms of the GNU Lesser General Public
28 | License as published by the Free Software Foundation; either
29 | version 2.1 of the License, or (at your option) any later version.
30 |
31 | The GNU C Library is distributed in the hope that it will be useful,
32 | but WITHOUT ANY WARRANTY; without even the implied warranty of
33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 | Lesser General Public License for more details.
35 |
36 | You should have received a copy of the GNU Lesser General Public
37 | License along with the GNU C Library; if not, see
38 | . */
39 |
40 | #include
41 | #include
42 |
43 | #include "localeinfo.h"
44 |
45 |
46 | /* Lock for protecting global data. */
47 | __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
48 |
49 |
50 | __locale_t
51 | __duplocale (__locale_t dataset)
52 | {
53 |
54 | #if 1
55 |
56 | return dataset;
57 |
58 | #else
59 |
60 | /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */
61 | if (dataset == _nl_C_locobj_ptr)
62 | return dataset;
63 |
64 | /* Handle a special value. */
65 | if (dataset == LC_GLOBAL_LOCALE)
66 | dataset = &_nl_global_locale;
67 |
68 | __locale_t result;
69 | int cnt;
70 | size_t names_len = 0;
71 |
72 | /* Calculate the total space we need to store all the names. */
73 | for (cnt = 0; cnt < __LC_LAST; ++cnt)
74 | if (cnt != LC_ALL && dataset->__names[cnt] != _nl_C_name)
75 | names_len += strlen (dataset->__names[cnt]) + 1;
76 |
77 | /* Get memory. */
78 | result = malloc (sizeof (struct __locale_struct) + names_len);
79 |
80 | if (result != NULL)
81 | {
82 | char *namep = (char *) (result + 1);
83 |
84 | /* We modify global data (the usage counts). */
85 | __libc_rwlock_wrlock (__libc_setlocale_lock);
86 |
87 | for (cnt = 0; cnt < __LC_LAST; ++cnt)
88 | if (cnt != LC_ALL)
89 | {
90 | result->__locales[cnt] = dataset->__locales[cnt];
91 | if (result->__locales[cnt]->usage_count < MAX_USAGE_COUNT)
92 | ++result->__locales[cnt]->usage_count;
93 |
94 | if (dataset->__names[cnt] == _nl_C_name)
95 | result->__names[cnt] = _nl_C_name;
96 | else
97 | {
98 | result->__names[cnt] = namep;
99 | namep = __stpcpy (namep, dataset->__names[cnt]) + 1;
100 | }
101 | }
102 |
103 | /* Update the special members. */
104 | result->__ctype_b = dataset->__ctype_b;
105 | result->__ctype_tolower = dataset->__ctype_tolower;
106 | result->__ctype_toupper = dataset->__ctype_toupper;
107 |
108 | /* It's done. */
109 | __libc_rwlock_unlock (__libc_setlocale_lock);
110 | }
111 |
112 | return result;
113 |
114 | #endif
115 |
116 | }
117 | __typeof ( __duplocale ) duplocale __attribute__(( weak , alias( "__duplocale" )) ) ;
118 |
--------------------------------------------------------------------------------
/libmy/errno.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * This file is part of UEFI fdisk.
4 | *
5 | * UEFI fdisk is a port of util-linux fdisk to UEFI/BIOS.
6 | * UEFI fdisk est un portage de util-linux fdisk vers UEFI/BIOS.
7 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
8 | *
9 | * All this work is copyleft Bernard Burette.
10 | * Gauche d'auteur Bernard Burette.
11 | *
12 | * This program is distributed under the terms of the GNU General Public
13 | * License version 2 or more.
14 | * La diffusion de ce code est faite selon les termes de la licence publique
15 | * générale GNU version 2 ou plus.
16 | *
17 | */
18 | #include "libmy.h"
19 | #include
20 | #ifdef errno
21 | # undef errno
22 | #endif
23 | /*
24 | * Error related.
25 | */
26 | __thread int errno ;
27 | extern __thread int __libc_errno __attribute__((alias ("errno"))) ;
28 | int *__errno_location (void)
29 | {
30 | return & errno ;
31 | }
32 | __THROW __attribute_const__
33 | __typeof (__errno_location) errno_location __attribute__((weak, alias("__errno_location"))) ;
34 |
--------------------------------------------------------------------------------
/libmy/fclose.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #undef __USE_EXTERN_INLINES
20 | #include
21 | #include
22 | #include
23 |
24 | int fclose_unlocked(FILE *stream) {
25 | int res;
26 | /*FILE *f,*fl;*/
27 | /* no buffers, no flush needed
28 | res=fflush_unlocked(stream);
29 | */
30 | /*res|=__libc_close(stream->fd);*/
31 | res = close( stream-> _fileno ) ;
32 | if ( res < 0 ) res = EOF ;
33 | /*
34 | for (fl=0,f=__stdio_root; f; fl=f,f=f->next)
35 | if (f==stream) {
36 | if (fl)
37 | fl->next=f->next;
38 | else
39 | __stdio_root=f->next;
40 | break;
41 | }
42 | */
43 | /* no buffers
44 | if ((!(stream->flags&STATICBUF))&&(stream->buf))
45 | free(stream->buf);
46 | */
47 | if ( stream != stdin && stream != stdout && stream != stderr ) {
48 | free(stream);
49 | }
50 | return res;
51 | }
52 |
53 | int fclose(FILE *stream) __attribute__((weak,alias("fclose_unlocked")));
54 |
55 |
--------------------------------------------------------------------------------
/libmy/fdopen.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Entrée sortie FILE de stdio.
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "libmy.h"
24 | #include
25 |
26 |
27 | /**
28 | * fdopen() : ouverture d'après un descripteur.
29 | */
30 | FILE *
31 | fdopen( fd , mode )
32 | int fd __attribute__((unused)) ;
33 | const char * mode __attribute__((unused)) ;
34 | {
35 | __fortify_fail( "fdopen()" ) ;
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/libmy/fflush.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 |
21 | int fflush_unlocked( stream )
22 | FILE * stream ;
23 | {
24 | /* no buffers */
25 | setvbuf( stream , NULL , _IONBF , 0 ) ;
26 | /* we dit it ! */
27 | return 0 ;
28 | }
29 |
30 | int fflush(FILE *stream) __attribute__((weak,alias("fflush_unlocked")));
31 |
32 |
--------------------------------------------------------------------------------
/libmy/fgetc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 |
22 | #ifdef getc
23 | # undef getc
24 | #endif
25 |
26 | #define GETC_UNGETC 0x100
27 | #if GETC_UNGETC == _IO_EOF_SEEN
28 | # error GETC_UNGETC == _IO_EOF_SEEN
29 | #endif
30 |
31 | int ungetc( c , stream )
32 | int c ;
33 | FILE * stream ;
34 | {
35 | /* jamais de buffering ici */
36 | /* inutile setvbuf( stream , NULL , _IONBF , 0 ) ; */
37 | /* on ne relit pas EOF */
38 | if ( c == EOF ) return EOF ;
39 | /* si déjà un UNGET */
40 | if ( stream-> _flags2 & GETC_UNGETC ) {
41 | return EOF ;
42 | }
43 | /* note la valeur du caractère à relire */
44 | stream-> _shortbuf[ 0 ] = (char) c ;
45 | /* passe EOF dans flags2 et note la présence du caractère à relire */
46 | stream-> _flags2 |= ( GETC_UNGETC |
47 | ( stream-> _flags & _IO_EOF_SEEN ) ) ;
48 | /* enlève erreur et fin de fichier du flux */
49 | stream-> _flags &= ~ ( _IO_ERR_SEEN | _IO_EOF_SEEN ) ;
50 | /* retourne le caractère remis dans le flux */
51 | return c ;
52 | }
53 |
54 | int fgetc( stream )
55 | FILE * stream __attribute__((unused)) ;
56 | {
57 | char c ;
58 | /* jamais de buffering ici */
59 | setvbuf( stream , NULL , _IONBF , 0 ) ;
60 | /* s'il y a un caractère à relire en attente */
61 | if ( stream-> _flags2 & GETC_UNGETC ) {
62 | /* récupère le caractère */
63 | c = stream -> _shortbuf[ 0 ] ;
64 | /* repasse l'indicateur EOF dans _flags */
65 | stream-> _flags |= stream-> _flags2 & _IO_EOF_SEEN ;
66 | /* remet flags2 en état normal */
67 | stream-> _flags2 &= ~ ( GETC_UNGETC | _IO_EOF_SEEN ) ;
68 | } else {
69 | int n ;
70 | n = read( stream-> _fileno , & c , 1 ) ;
71 | if ( n < 0 ) {
72 | /* note l'erreur */
73 | stream-> _flags |= _IO_ERR_SEEN ;
74 | return EOF ;
75 | }
76 | if ( n != 1 ) {
77 | /* note la fin de fichier */
78 | stream-> _flags |= _IO_EOF_SEEN ;
79 | return EOF ;
80 | }
81 | }
82 | return (unsigned char) c ;
83 | }
84 |
85 | __typeof( fgetc ) getc __attribute__((weak,alias("fgetc"))) ;
86 |
87 |
--------------------------------------------------------------------------------
/libmy/fgets.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #include "dietstdio.h"
21 |
22 | char *fgets_unlocked(char *s, int size, FILE *stream) {
23 | int l;
24 | for (l=0; l
19 |
20 | #ifdef getwc
21 | # undef getwc
22 | #endif
23 |
24 | wint_t ungetwc( wc , stream )
25 | wint_t wc __attribute__((unused)) ;
26 | FILE * stream __attribute__((unused)) ;
27 | {
28 | __fortify_fail( "ungetwc()" ) ;
29 | }
30 |
31 | wint_t fgetwc( stream )
32 | FILE * stream __attribute__((unused)) ;
33 | {
34 | __fortify_fail( "fgetwc()" ) ;
35 | }
36 |
37 | __typeof( fgetwc ) getwc __attribute__((weak,alias("fgetwc"))) ;
38 |
39 |
--------------------------------------------------------------------------------
/libmy/fileno.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 |
22 | int fileno( stream )
23 | FILE * stream ;
24 | {
25 | return stream-> _fileno ;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/fopen.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * Original work is copyleft Bernard Burette.
9 | * Modifications are copyleft Joseph Zeller.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Entrée sortie FILE de stdio.
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "libmy.h"
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | int
30 | open( const char *pathname __attribute__((unused)) ,
31 | int flags __attribute__((unused)) ,
32 | ... )
33 | {
34 | __fortify_fail( "open()" ) ;
35 | }
36 |
37 | /**
38 | * fopen : ouverture d'un flux.
39 | */
40 | #undef fopen
41 | FILE *
42 | fopen( name , mode )
43 | const char * name __attribute__((unused)) ;
44 | const char * mode __attribute__((unused)) ;
45 | {
46 | /* TODO: ? */
47 | __fortify_fail( "fopen()" ) ;
48 | }
49 |
50 | __attribute_malloc__ __attr_dealloc_fclose __wur
51 | __typeof( fopen ) fopen64 __attribute__(( weak , alias( "fopen" ) )) ;
52 |
53 |
--------------------------------------------------------------------------------
/libmy/fputc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 |
22 | #ifdef putc
23 | # undef putc
24 | #endif
25 |
26 | int fputc( c , stream )
27 | int c ;
28 | FILE * stream ;
29 | {
30 | unsigned char bc ;
31 | bc = (unsigned char) c ;
32 | /* jamais de buffering ici */
33 | setvbuf( stream , NULL , _IONBF , 0 ) ;
34 | if ( write( stream-> _fileno , & bc , 1 ) != 1 ) {
35 | stream-> _flags |= _IO_ERR_SEEN ;
36 | return EOF ;
37 | }
38 | return c ;
39 | }
40 |
41 | __typeof( fputc ) putc __attribute__((weak,alias("fputc"))) ;
42 |
43 |
--------------------------------------------------------------------------------
/libmy/fputs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | #include "dietstdio.h"
22 |
23 | int fputs_unlocked(const char*s,FILE*stream) {
24 | return fwrite(s,strlen(s),1,stream);
25 | }
26 |
27 | int fputs(const char*s,FILE*stream) __attribute__((weak,alias("fputs_unlocked")));
28 |
--------------------------------------------------------------------------------
/libmy/fputwc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #ifdef putwc
21 | # undef putwc
22 | #endif
23 |
24 | wint_t fputwc(
25 | wchar_t wc __attribute__((unused)) ,
26 | FILE *stream __attribute__((unused))
27 | )
28 | {
29 | __fortify_fail( "fputwc()" ) ;
30 | }
31 |
32 | __typeof( fputwc ) putwc __attribute__((weak,alias("fputwc"))) ;
33 |
34 |
--------------------------------------------------------------------------------
/libmy/fread.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 |
22 | size_t fread_unlocked( ptr , size , count , stream )
23 | void * ptr ;
24 | size_t size ;
25 | size_t count ;
26 | FILE * stream ;
27 | {
28 | char * p ; /* l'adresse où stocker ce qui est lu */
29 | size_t n ; /* le nombre d'items lus */
30 | char premier = 1 ; /* la première lecture */
31 | /* jamais de buffering ici */
32 | setvbuf( stream , NULL , _IONBF , 0 ) ;
33 | p = (char *) ptr ;
34 | n = 0 ;
35 | while ( count ) {
36 | ssize_t s ; /* la taille de cet item */
37 | s = size ;
38 | while ( s ) {
39 | ssize_t r ;
40 | if ( premier ) {
41 | /* gestion du ungetc() */
42 | char c = fgetc( stream ) ;
43 | /* fin de fichier ou erreur */
44 | if ( c == EOF ) goto ret ;
45 | /* stocke l'octet et avance */
46 | * p = c ;
47 | p ++ ;
48 | s -- ;
49 | premier = 0 ;
50 | }
51 | /* lit un item */
52 | r = read( stream-> _fileno , p , s ) ;
53 | if ( r < 0 ) {
54 | /* note l'erreur */
55 | stream-> _flags |= _IO_ERR_SEEN ;
56 | goto ret ;
57 | }
58 | if ( r < s ) {
59 | /* note la fin de fichier */
60 | stream-> _flags |= _IO_EOF_SEEN ;
61 | goto ret ;
62 | }
63 | p += r ;
64 | s -= r ;
65 | }
66 | count -- ;
67 | n ++ ;
68 | }
69 | ret : ;
70 | return n ;
71 | }
72 |
73 | __typeof( fread_unlocked ) fread __attribute__((weak,alias("fread_unlocked"))) ;
74 |
75 |
--------------------------------------------------------------------------------
/libmy/freelocale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "ctype.h"
21 | /* Free data allocated by a call to setlocale_r
22 | Copyright (C) 1996-2013 Free Software Foundation, Inc.
23 | This file is part of the GNU C Library.
24 | Contributed by Ulrich Drepper , 1996.
25 |
26 | The GNU C Library is free software; you can redistribute it and/or
27 | modify it under the terms of the GNU Lesser General Public
28 | License as published by the Free Software Foundation; either
29 | version 2.1 of the License, or (at your option) any later version.
30 |
31 | The GNU C Library is distributed in the hope that it will be useful,
32 | but WITHOUT ANY WARRANTY; without even the implied warranty of
33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 | Lesser General Public License for more details.
35 |
36 | You should have received a copy of the GNU Lesser General Public
37 | License along with the GNU C Library; if not, see
38 | . */
39 |
40 | #include
41 | #include "localeinfo.h"
42 |
43 |
44 | /* Lock for protecting global data. */
45 | __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
46 |
47 |
48 | void
49 | __freelocale (__locale_t dataset __attribute__((unused)) )
50 | {
51 | #if 0
52 |
53 |
54 | int cnt;
55 |
56 | /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */
57 | if (dataset == _nl_C_locobj_ptr)
58 | return;
59 |
60 | /* We modify global data (the usage counts). */
61 | __libc_rwlock_wrlock (__libc_setlocale_lock);
62 |
63 | for (cnt = 0; cnt < __LC_LAST; ++cnt)
64 | if (cnt != LC_ALL && dataset->__locales[cnt]->usage_count != UNDELETABLE)
65 | /* We can remove the data. */
66 | _nl_remove_locale (cnt, dataset->__locales[cnt]);
67 |
68 | /* It's done. */
69 | __libc_rwlock_unlock (__libc_setlocale_lock);
70 |
71 | /* Free the locale_t handle itself. */
72 | free (dataset);
73 |
74 |
75 |
76 | #endif
77 | }
78 | __typeof ( __freelocale ) freelocale __attribute__(( weak , alias( "__freelocale" )) ) ;
79 |
--------------------------------------------------------------------------------
/libmy/fseeko64.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | /* needed to get definition of "off64_t" from sys/stat.h
19 | do this first otherwise file "sys/types.h" will have already
20 | been included by others. */
21 | #define _LARGEFILE64_SOURCE 1
22 | #include
23 | #include "libmy.h"
24 | #include
25 | /* for lseek64 */
26 | #include
27 | #include
28 |
29 | int fseeko64( stream , off , whence )
30 | FILE * stream ;
31 | off64_t off ;
32 | int whence ;
33 | {
34 | off64_t p ;
35 | p = lseek64( stream-> _fileno , off , whence ) ;
36 | if ( p == -1 ) return -1 ;
37 | return 0 ;
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/libmy/ftello64.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | /* needed to get definition of "off64_t" from sys/stat.h
19 | do this first otherwise file "sys/types.h" will have already
20 | been included by others. */
21 | #define _LARGEFILE64_SOURCE 1
22 | #include
23 | #include "libmy.h"
24 | #include
25 | /* for lseek64 */
26 | #include
27 |
28 | off64_t ftello64( stream )
29 | FILE * stream ;
30 | {
31 | return lseek64( stream-> _fileno , 0 , SEEK_CUR ) ;
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/libmy/fwrite.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 | #include
22 |
23 | #ifdef fwrite_unlocked
24 | # undef fwrite_unlocked
25 | #endif
26 |
27 | size_t fwrite_unlocked( ptr , size , count , stream )
28 | const void * ptr ;
29 | size_t size ;
30 | size_t count ;
31 | FILE * stream ;
32 | {
33 | const char * p ;
34 | size_t n ;
35 | /* jamais de buffering ici */
36 | setvbuf( stream , NULL , _IONBF , 0 ) ;
37 | p = (const char *) ptr ;
38 | n = 0 ;
39 | while ( count ) {
40 | if ( write( stream-> _fileno , p , size ) != (ssize_t) size ) {
41 | stream-> _flags |= _IO_ERR_SEEN ;
42 | break ;
43 | }
44 | p += size ;
45 | count -- ;
46 | n ++ ;
47 | }
48 | return n ;
49 | }
50 |
51 | __typeof( fwrite_unlocked ) fwrite __attribute__((weak,alias("fwrite_unlocked"))) ;
52 |
53 |
--------------------------------------------------------------------------------
/libmy/getentropy.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int getentropy (buffer, length)
21 | void *buffer __attribute__((unused)) ;
22 | size_t length __attribute__((unused)) ;
23 | {
24 | __fortify_fail( "getentropy()" ) ;
25 | }
26 |
--------------------------------------------------------------------------------
/libmy/gettext.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #undef gettext
21 | char* gettext( msgid )
22 | const char* msgid ;
23 | {
24 | return (char*) msgid ;
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/libmy/gettimeofday.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * Original work is copyleft Bernard Burette.
9 | * Modifications are copyleft Joseph Zeller.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /* en premier */
16 | #include "libmy.h"
17 | #include
18 |
19 |
20 | /**
21 | * gettimeofday : date/heure locale.
22 | */
23 | int
24 | gettimeofday( tv , tz )
25 | struct timeval *tv __attribute__(( unused )) ;
26 | void *tz __attribute__(( unused )) ;
27 | {
28 | /* TODO: ? */
29 | __fortify_fail( "gettimeofday()" ) ;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libmy/global-locale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _GNU_SOURCE
18 | #define _XOPEN_SOURCE 600
19 | #include "libmy.h"
20 | #include "libc-tsd.h"
21 | #include "locale.h"
22 | #include "localeinfo.h"
23 | #include "ctype.h"
24 | /* Locale object representing the global locale controlled by setlocale.
25 | Copyright (C) 2002-2013 Free Software Foundation, Inc.
26 | This file is part of the GNU C Library.
27 |
28 | The GNU C Library is free software; you can redistribute it and/or
29 | modify it under the terms of the GNU Lesser General Public
30 | License as published by the Free Software Foundation; either
31 | version 2.1 of the License, or (at your option) any later version.
32 |
33 | The GNU C Library is distributed in the hope that it will be useful,
34 | but WITHOUT ANY WARRANTY; without even the implied warranty of
35 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 | Lesser General Public License for more details.
37 |
38 | You should have received a copy of the GNU Lesser General Public
39 | License along with the GNU C Library; if not, see
40 | . */
41 |
42 | #include
43 | #include "localeinfo.h"
44 |
45 | #define DEFINE_CATEGORY(category, category_name, items, a) \
46 | extern struct __locale_data _nl_C_##category; weak_extern (_nl_C_##category)
47 | #include "categories.def"
48 | #undef DEFINE_CATEGORY
49 |
50 | /* Defined in locale/C-ctype.c. */
51 | extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
52 | extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
53 | extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
54 | weak_extern (_nl_C_LC_CTYPE_class)
55 | weak_extern (_nl_C_LC_CTYPE_toupper)
56 | weak_extern (_nl_C_LC_CTYPE_tolower)
57 |
58 | /* Here we define the locale object maintained by setlocale.
59 | The references in the initializer are weak, so the parts of
60 | the structure that are never referred to will be zero. */
61 |
62 | struct __locale_struct _nl_global_locale attribute_hidden =
63 | {
64 | .__locales =
65 | {
66 | #define DEFINE_CATEGORY(category, category_name, items, a) \
67 | [category] = &_nl_C_##category,
68 | #include "categories.def"
69 | #undef DEFINE_CATEGORY
70 | },
71 | .__names =
72 | {
73 | [LC_ALL] = _nl_C_name,
74 | #define DEFINE_CATEGORY(category, category_name, items, a) \
75 | [category] = _nl_C_name,
76 | #include "categories.def"
77 | #undef DEFINE_CATEGORY
78 | },
79 | .__ctype_b = (const unsigned short int *) _nl_C_LC_CTYPE_class + 128,
80 | .__ctype_tolower = (const int *) _nl_C_LC_CTYPE_tolower + 128,
81 | .__ctype_toupper = (const int *) _nl_C_LC_CTYPE_toupper + 128
82 | };
83 |
84 | #include "tls.h"
85 |
86 | /* The tsd macros don't permit an initializer. */
87 |
88 | __thread __locale_t __libc_tsd_LOCALE = &_nl_global_locale;
89 |
90 |
--------------------------------------------------------------------------------
/libmy/iconv.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t
21 | iconv (cd, inbuf, inbytesleft, outbuf, outbytesleft)
22 | iconv_t cd __attribute__(( unused )) ;
23 | char **inbuf __attribute__(( unused )) ;
24 | size_t *inbytesleft __attribute__(( unused )) ;
25 | char **outbuf __attribute__(( unused )) ;
26 | size_t *outbytesleft __attribute__(( unused )) ;
27 |
28 | {
29 | __fortify_fail( "iconv()" ) ;
30 | /*
31 | return NULL ;
32 | */
33 | }
34 |
--------------------------------------------------------------------------------
/libmy/iconv_close.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int
21 | iconv_close (cd)
22 | iconv_t cd __attribute__(( unused )) ;
23 | {
24 | __fortify_fail( "iconv_close()" ) ;
25 | /*
26 | return NULL ;
27 | */
28 | }
29 |
--------------------------------------------------------------------------------
/libmy/iconv_open.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | iconv_t
21 | iconv_open (tocode, fromcode)
22 | const char *tocode __attribute__(( unused )) ;
23 | const char *fromcode __attribute__(( unused )) ;
24 | {
25 | __fortify_fail( "iconv_open()" ) ;
26 | /*
27 | return NULL ;
28 | */
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/libmy/iswctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 |
22 | int __iswctype_l( wc , desc , locale )
23 | wint_t wc __attribute__((unused)) ;
24 | wctype_t desc __attribute__((unused)) ;
25 | __locale_t locale __attribute__((unused)) ;
26 | {
27 | /* TODO: ? */
28 | __fortify_fail( "__iswctype_l()" ) ;
29 | }
30 |
31 | __typeof( __iswctype_l ) iswctype_l __attribute__((weak,alias("__iswctype_l"))) ;
32 |
33 | int __iswctype( wc , desc )
34 | wint_t wc __attribute__((unused)) ;
35 | wctype_t desc __attribute__((unused)) ;
36 | {
37 | return iswctype_l( wc , desc , NULL ) ;
38 | }
39 |
40 | __typeof( __iswctype ) iswctype __attribute__((weak,alias("__iswctype"))) ;
41 |
42 |
--------------------------------------------------------------------------------
/libmy/lc-ctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "localeinfo.h"
21 | #include "ctype.h"
22 | /* Define current locale data for LC_CTYPE category.
23 | Copyright (C) 1995-2013 Free Software Foundation, Inc.
24 | This file is part of the GNU C Library.
25 |
26 | The GNU C Library is free software; you can redistribute it and/or
27 | modify it under the terms of the GNU Lesser General Public
28 | License as published by the Free Software Foundation; either
29 | version 2.1 of the License, or (at your option) any later version.
30 |
31 | The GNU C Library is distributed in the hope that it will be useful,
32 | but WITHOUT ANY WARRANTY; without even the implied warranty of
33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 | Lesser General Public License for more details.
35 |
36 | You should have received a copy of the GNU Lesser General Public
37 | License along with the GNU C Library; if not, see
38 | . */
39 |
40 | #include "localeinfo.h"
41 | #include
42 | #include
43 | #include
44 |
45 | _NL_CURRENT_DEFINE (LC_CTYPE);
46 |
47 | /* We are called after loading LC_CTYPE data to load it into
48 | the variables used by the ctype.h macros. */
49 |
50 | extern __thread __locale_t _NL_CURRENT_LOCALE ;
51 |
52 | void
53 | _nl_postload_ctype (void)
54 | {
55 | #define current(type,x,offset) \
56 | ((const type *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_##x) + offset)
57 |
58 | const union locale_data_value *const ctypes
59 | = _nl_global_locale.__locales[LC_CTYPE]->values;
60 |
61 | /* These thread-local variables are defined in ctype-info.c.
62 | The declarations here must match those in localeinfo.h.
63 |
64 | These point into arrays of 384, so they can be indexed by any `unsigned
65 | char' value [0,255]; by EOF (-1); or by any `signed char' value
66 | [-128,-1). ISO C requires that the ctype functions work for `unsigned
67 | char' values and for EOF; we also support negative `signed char' values
68 | for broken old programs. The case conversion arrays are of `int's
69 | rather than `unsigned char's because tolower (EOF) must be EOF, which
70 | doesn't fit into an `unsigned char'. But today more important is that
71 | the arrays are also used for multi-byte character sets.
72 |
73 | First we update the special members of _nl_global_locale as newlocale
74 | would. This is necessary for uselocale (LC_GLOBAL_LOCALE) to find these
75 | values properly. */
76 |
77 | _nl_global_locale.__ctype_b = (const unsigned short int *)
78 | ctypes[_NL_ITEM_INDEX (_NL_CTYPE_CLASS)].string + 128;
79 | _nl_global_locale.__ctype_tolower = (const int *)
80 | ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER)].string + 128;
81 | _nl_global_locale.__ctype_toupper = (const int *)
82 | ctypes[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER)].string + 128;
83 |
84 | /* Next we must set the thread-local caches if and only if this thread is
85 | in fact using the global locale. */
86 | if (_NL_CURRENT_LOCALE == &_nl_global_locale)
87 | {
88 | __libc_tsd_set (const uint16_t *, CTYPE_B,
89 | (void *) _nl_global_locale.__ctype_b);
90 | __libc_tsd_set (const int32_t *, CTYPE_TOUPPER,
91 | (void *) _nl_global_locale.__ctype_toupper);
92 | __libc_tsd_set (const int32_t *, CTYPE_TOLOWER,
93 | (void *) _nl_global_locale.__ctype_tolower);
94 | }
95 |
96 |
97 |
98 | /* #include */
99 | /* #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) */
100 |
101 | #if 1
102 |
103 |
104 |
105 | /* We must use the exported names to access these so we are sure to
106 | be accessing the main executable's copy if it has COPY relocs. */
107 |
108 | extern const unsigned short int *__ctype_b; /* Characteristics. */
109 | extern const __int32_t *__ctype_tolower; /* Case conversions. */
110 | extern const __int32_t *__ctype_toupper; /* Case conversions. */
111 |
112 | extern const uint32_t *__ctype32_b;
113 | extern const uint32_t *__ctype32_toupper;
114 | extern const uint32_t *__ctype32_tolower;
115 |
116 | /* We need the .symver declarations these macros generate so that
117 | our references are explicitly bound to the versioned symbol names
118 | rather than the unadorned names that are not exported. When the
119 | linker sees these bound to local symbols (as the unexported names are)
120 | then it doesn't generate a proper relocation to the global symbols.
121 | We need those relocations so that a versioned definition with a COPY
122 | reloc in an executable will override the libc.so definition. */
123 |
124 | compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
125 | compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
126 | compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
127 | compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
128 | compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
129 | compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
130 |
131 | __ctype_b = current (uint16_t, CLASS, 128);
132 | __ctype_toupper = current (int32_t, TOUPPER, 128);
133 | __ctype_tolower = current (int32_t, TOLOWER, 128);
134 | __ctype32_b = current (uint32_t, CLASS32, 0);
135 | __ctype32_toupper = current (uint32_t, TOUPPER32, 0);
136 | __ctype32_tolower = current (uint32_t, TOLOWER32, 0);
137 | #endif
138 | }
139 |
--------------------------------------------------------------------------------
/libmy/libc-tsd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 |
19 | /* Not using threads here */
20 |
21 | /* libc-internal interface for thread-specific data. Stub or TLS version.
22 | Copyright (C) 1998-2013 Free Software Foundation, Inc.
23 | This file is part of the GNU C Library.
24 |
25 | The GNU C Library is free software; you can redistribute it and/or
26 | modify it under the terms of the GNU Lesser General Public
27 | License as published by the Free Software Foundation; either
28 | version 2.1 of the License, or (at your option) any later version.
29 |
30 | The GNU C Library is distributed in the hope that it will be useful,
31 | but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 | Lesser General Public License for more details.
34 |
35 | You should have received a copy of the GNU Lesser General Public
36 | License along with the GNU C Library; if not, see
37 | . */
38 |
39 | #ifndef _GENERIC_BITS_LIBC_TSD_H
40 | #define _GENERIC_BITS_LIBC_TSD_H 1
41 |
42 | /* This file defines the following macros for accessing a small fixed
43 | set of thread-specific `void *' data used only internally by libc.
44 |
45 | __libc_tsd_define(CLASS, TYPE, KEY) -- Define or declare a datum with TYPE
46 | for KEY. CLASS can be `static' for
47 | keys used in only one source file,
48 | empty for global definitions, or
49 | `extern' for global declarations.
50 | __libc_tsd_address(TYPE, KEY) -- Return the `TYPE *' pointing to
51 | the current thread's datum for KEY.
52 | __libc_tsd_get(TYPE, KEY) -- Return the `TYPE' datum for KEY.
53 | __libc_tsd_set(TYPE, KEY, VALUE) -- Set the datum for KEY to VALUE.
54 |
55 | The set of available KEY's will usually be provided as an enum,
56 | and contains (at least):
57 | _LIBC_TSD_KEY_MALLOC
58 | _LIBC_TSD_KEY_DL_ERROR
59 | _LIBC_TSD_KEY_RPC_VARS
60 | All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
61 | Some implementations may not provide any enum at all and instead
62 | using string pasting in the macros. */
63 |
64 | #include "tls.h"
65 |
66 | /* When full support for __thread variables is available, this interface is
67 | just a trivial wrapper for it. Without TLS, this is the generic/stub
68 | implementation for wholly single-threaded systems.
69 |
70 | We don't define an enum for the possible key values, because the KEYs
71 | translate directly into variables by macro magic. */
72 |
73 | #define __libc_tsd_define(CLASS, TYPE, KEY) \
74 | CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie;
75 |
76 | #define __libc_tsd_address(TYPE, KEY) (&__libc_tsd_##KEY)
77 | #define __libc_tsd_get(TYPE, KEY) (__libc_tsd_##KEY)
78 | #define __libc_tsd_set(TYPE, KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
79 |
80 | #endif /* bits/libc-tsd.h */
81 |
--------------------------------------------------------------------------------
/libmy/libmy.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | /* Pas de double inclusion. */
18 | #ifndef libmy_h_INCLUDED
19 | #define libmy_h_INCLUDED
20 |
21 | #define __dietlibc__
22 |
23 | /* for types like size_t */
24 | #include
25 |
26 | /* This file could be included by C++ source files */
27 | #if defined(__cplusplus)
28 | extern "C" {
29 | #endif
30 |
31 | extern void __fortify_fail( const char * msg ) __attribute__((noreturn)) ;
32 |
33 | extern int __ltostr( char * s , size_t size , long i ,
34 | unsigned int base , char UpCase ) ;
35 |
36 | extern int __lltostr( char * s , size_t size , long long i ,
37 | unsigned int base , char UpCase ) ;
38 |
39 | #if defined(__cplusplus)
40 | }
41 | #endif
42 |
43 | /* Locale management imported from GNU stdlib uses a lot of these macros,
44 | we don't need them in our simple implementation */
45 | #define __libc_rwlock_define(CLASS,NAME)
46 | #define __libc_lock_lock(NAME)
47 | #define __libc_rwlock_rdlock(NAME)
48 | #define __libc_rwlock_wrlock(NAME)
49 | #define __libc_lock_unlock(NAME)
50 | #define __libc_rwlock_unlock(NAME)
51 | #define compat_symbol( libc , name1 , name2 , version )
52 | #define __SYMBOL_PREFIX
53 | #define libc_hidden_proto(name, attrs...)
54 | #define libc_hidden_def(name)
55 | #define attribute_hidden
56 | #define internal_function /* empty */
57 | #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
58 | #define weak_extern(expr)
59 |
60 | #endif /* libmy_h_INCLUDED */
61 |
62 |
--------------------------------------------------------------------------------
/libmy/lltostr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "dietfeatures.h"
19 | #include
20 |
21 | int __lltostr( s , size , i , base , UpCase )
22 | char * s ;
23 | size_t size ;
24 | long long i ;
25 | unsigned int base ;
26 | char UpCase ;
27 | {
28 | char *tmp;
29 | unsigned int j=0;
30 |
31 | s[--size]=0;
32 |
33 | tmp=s+size;
34 |
35 | if ((base==0)||(base>36)) base=10;
36 |
37 | j=0;
38 | if (!i)
39 | {
40 | *(--tmp)='0';
41 | j=1;
42 | }
43 |
44 | while((tmp>s)&&(i))
45 | {
46 | tmp--;
47 | if ((*tmp=i%base+'0')>'9') *tmp+=(UpCase?'A':'a')-'9'-1;
48 | i=i/base;
49 | j++;
50 | }
51 | memmove(s,tmp,j+1);
52 |
53 | return j;
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/libmy/locale.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #ifndef _LOCALE_H
19 | #include
20 |
21 | extern locale_t uselocale (locale_t newloc) ;
22 |
23 | #ifndef _ISOMAC
24 | extern __typeof (uselocale) __uselocale;
25 |
26 | libc_hidden_proto (setlocale)
27 | libc_hidden_proto (__uselocale)
28 |
29 | /* This has to be changed whenever a new locale is defined. */
30 | #define __LC_LAST 13
31 |
32 | extern struct loaded_l10nfile *_nl_locale_file_list[] attribute_hidden;
33 |
34 | /* Locale object for C locale. */
35 | extern const struct __locale_struct _nl_C_locobj attribute_hidden;
36 | #define _nl_C_locobj_ptr ((struct __locale_struct *) &_nl_C_locobj)
37 |
38 | /* Now define the internal interfaces. */
39 | extern struct lconv *__localeconv (void);
40 |
41 | /* Fetch the name of the current locale set in the given category. */
42 | extern const char *__current_locale_name (int category) attribute_hidden;
43 |
44 | #endif
45 | #endif
46 |
--------------------------------------------------------------------------------
/libmy/ltostr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int __ltostr( s , size , i , base , UpCase )
21 | char * s ;
22 | size_t size ;
23 | long i ;
24 | unsigned int base ;
25 | char UpCase ;
26 | {
27 | char *tmp;
28 | unsigned int j=0;
29 |
30 | s[--size]=0;
31 |
32 | tmp=s+size;
33 |
34 | if ((base==0)||(base>36)) base=10;
35 |
36 | j=0;
37 | if (!i)
38 | {
39 | *(--tmp)='0';
40 | j=1;
41 | }
42 |
43 | while((tmp>s)&&(i))
44 | {
45 | tmp--;
46 | if ((*tmp=i%base+'0')>'9') *tmp+=(UpCase?'A':'a')-'9'-1;
47 | i=i/base;
48 | j++;
49 | }
50 | memmove(s,tmp,j+1);
51 |
52 | return j;
53 | }
54 |
55 | __typeof( __ltostr ) ltostr __attribute__((weak,alias("__ltostr"))) ;
56 |
57 |
--------------------------------------------------------------------------------
/libmy/mbrtowc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t mbrtowc( pwc , s , n , ps )
21 | wchar_t * pwc __attribute__((unused)) ;
22 | const char * s __attribute__((unused)) ;
23 | size_t n __attribute__((unused)) ;
24 | mbstate_t * ps __attribute__((unused)) ;
25 | {
26 | /* TODO: ? */
27 | __fortify_fail( "mbrtowc()" ) ;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/libmy/mbsnrtowcs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t mbsnrtowcs( dest , src , nms , len , ps )
21 | wchar_t * dest __attribute__((unused)) ;
22 | const char** src __attribute__((unused)) ;
23 | size_t nms __attribute__((unused)) ;
24 | size_t len __attribute__((unused)) ;
25 | mbstate_t* ps __attribute__((unused)) ;
26 | {
27 | /* TODO: ? */
28 | __fortify_fail( "mbsnrtowcs()" ) ;
29 | }
30 |
31 | size_t __mbsnrtowcs_chk (dst, src, nmc, len, ps, dstlen)
32 | wchar_t *dst __attribute__((unused)) ;
33 | const char **src __attribute__((unused)) ;
34 | size_t nmc __attribute__((unused)) ;
35 | size_t len __attribute__((unused)) ;
36 | mbstate_t *ps __attribute__((unused)) ;
37 | size_t dstlen __attribute__((unused)) ;
38 | {
39 | __fortify_fail( "__mbsnrtowcs_chk()" ) ;
40 | }
41 |
--------------------------------------------------------------------------------
/libmy/mbsrtowcs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t mbsrtowcs( dest , src , max , ps )
21 | wchar_t * dest __attribute__((unused)) ;
22 | const char** src __attribute__((unused)) ;
23 | size_t max __attribute__((unused)) ;
24 | mbstate_t* ps __attribute__((unused)) ;
25 | {
26 | /* TODO: ? */
27 | __fortify_fail( "mbsrtowcs()" ) ;
28 | }
29 |
30 | size_t __mbsrtowcs_chk (dst, src, len, ps, dstlen)
31 | wchar_t *dst __attribute__((unused)) ;
32 | const char **src __attribute__((unused)) ;
33 | size_t len __attribute__((unused)) ;
34 | mbstate_t *ps __attribute__((unused)) ;
35 | size_t dstlen __attribute__((unused)) ;
36 | {
37 | __fortify_fail( "__mbsrtowcs_chk()" ) ;
38 | }
39 |
--------------------------------------------------------------------------------
/libmy/memchr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include "dietfeatures.h"
20 | #include "dietstring.h"
21 |
22 | void* memchr(const void *s, int c, size_t n) {
23 | const unsigned char *pc = (unsigned char *) s;
24 | for (;n--;pc++)
25 | if (*pc == c)
26 | return ((void *) pc);
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/libmy/memcmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | int memcmp( s1 , s2 , n )
22 | const void * s1 ;
23 | const void * s2 ;
24 | size_t n ;
25 | {
26 | const unsigned char * p1 = (const unsigned char *) s1 ;
27 | const unsigned char * p2 = (const unsigned char *) s2 ;
28 | size_t i ;
29 |
30 | for ( i = 0 ; i < n ; i ++ ) {
31 | if ( * p1 != * p2 ) {
32 | return * p1 > * p2 ? 1 : -1 ;
33 | }
34 | p1 ++ ;
35 | p2 ++ ;
36 | }
37 | return 0 ;
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/libmy/memcpy.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* fast memcpy -- Copyright (C) 2003 Thomas M. Ogrisegg */
19 |
20 | #include
21 | #include "dietfeatures.h"
22 | #include "dietstring.h"
23 |
24 | void *
25 | __attribute__((weak))
26 | memcpy (void *dst, const void *src, size_t n)
27 | {
28 | void *res = dst;
29 | unsigned char *c1, *c2;
30 | #ifdef WANT_SMALL_STRING_ROUTINES
31 | c1 = (unsigned char *) dst;
32 | c2 = (unsigned char *) src;
33 | while (n--) *c1++ = *c2++;
34 | return (res);
35 | #else
36 | int tmp;
37 | unsigned long *lx1 = NULL;
38 | const unsigned long *lx2 = NULL;
39 |
40 | if (!UNALIGNED(dst, src) && n > sizeof(unsigned long)) {
41 |
42 | if ((tmp = STRALIGN(dst))) {
43 | c1 = (unsigned char *) dst;
44 | c2 = (unsigned char *) src;
45 | while (tmp-- && n--)
46 | *c1++ = *c2++;
47 | if (n == (size_t) - 1)
48 | return (res);
49 | dst = c1;
50 | src = c2;
51 | }
52 |
53 | lx1 = (unsigned long *) dst;
54 | lx2 = (unsigned long *) src;
55 |
56 | for (; n >= sizeof(unsigned long); n -= sizeof(unsigned long))
57 | *lx1++ = *lx2++;
58 | }
59 |
60 | if (n) {
61 | c1 = (unsigned char *) (lx1?lx1:dst);
62 | c2 = (unsigned char *) (lx1?lx2:src);
63 | while (n--)
64 | *c1++ = *c2++;
65 | }
66 |
67 | return (res);
68 | #endif
69 | }
70 |
71 | void *
72 | __memcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen)
73 | {
74 | if (dstlen < len)
75 | __fortify_fail ("buffer overflow detected");
76 |
77 | return memcpy (dstpp, srcpp, len);
78 | }
79 |
--------------------------------------------------------------------------------
/libmy/memmove.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #define _POSIX_SOURCE 1
19 | #define _XOPEN_SOURCE
20 | #include
21 | #include
22 |
23 | void *memmove(void *dst, const void *src, size_t count)
24 | {
25 | char *a = dst;
26 | const char *b = src;
27 | if (src!=dst)
28 | {
29 | if (src>dst)
30 | {
31 | while (count--) *a++ = *b++;
32 | }
33 | else
34 | {
35 | a+=count-1;
36 | b+=count-1;
37 | while (count--) *a-- = *b--;
38 | }
39 | }
40 | return dst;
41 | }
42 |
--------------------------------------------------------------------------------
/libmy/memset.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | /* gcc is broken and has a non-SUSv2 compliant internal prototype.
22 | * This causes it to warn about a type mismatch here. Ignore it. */
23 | void* __attribute__((weak)) memset(void * dst, int s, size_t count) {
24 | register char * a = dst;
25 | count++; /* this actually creates smaller code than using count-- */
26 | while (--count)
27 | *a++ = s;
28 | return dst;
29 | }
30 |
31 | void *
32 | __memset_chk (void *dstpp, int c, size_t len, size_t dstlen)
33 | {
34 | if (dstlen < len)
35 | __fortify_fail ("buffer overflow detected");
36 |
37 | return memset (dstpp, c, len);
38 | }
39 |
--------------------------------------------------------------------------------
/libmy/nl_langinfo.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 |
22 | #define getenv(x) NULL
23 |
24 | static inline char* get_codeset(void) {
25 | /* this is normally only used to look for "UTF-8" */
26 | char* s=getenv("LC_CTYPE");
27 | if (!s) s=getenv("LC_ALL");
28 | if (!s) s="ANSI_X3.4-1968"; /* it's what glibc does */
29 | return s;
30 | }
31 |
32 | static const char sweekdays [7] [4] = {
33 | "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
34 | };
35 |
36 | static const char weekdays [7] [10] = {
37 | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
38 | };
39 |
40 | static const char smonths [12] [4] = {
41 | "Jan", "Feb", "Mar", "Apr", "May", "Jun",
42 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
43 | };
44 |
45 | static const char* months [12] = {
46 | "January", "February", "March", "April", smonths[5-1], "June",
47 | "July", "August", "September", "October", "November", "December"
48 | };
49 |
50 | char* nl_langinfo(nl_item x) {
51 | if (x>=DAY_1 && x<=DAY_7) return (char*)weekdays[x-DAY_1];
52 | if (x>=ABDAY_1 && x<=ABDAY_7) return (char*)sweekdays[x-ABDAY_1];
53 | if (x>=MON_1 && x<=MON_12) return (char*)months[x-MON_1];
54 | if (x>=ABMON_1 && x<=ABMON_12) return (char*)smonths[x-ABMON_1];
55 | switch (x) {
56 | case CODESET: return get_codeset();
57 | case D_T_FMT: return "%b %a %d %k:%M:%S %Z %Y";
58 | case D_FMT: return "%b %a %d";
59 | case T_FMT: return "%H:%M";
60 | case T_FMT_AMPM: return "%I:%M:%S %p";
61 | case AM_STR: return "am";
62 | case PM_STR: return "pm";
63 | case ERA: return 0;
64 | case ERA_D_FMT: case ERA_D_T_FMT: case ERA_T_FMT: case ALT_DIGITS: return "";
65 | case RADIXCHAR: return ".";
66 | case THOUSEP: return "";
67 | case YESEXPR: return "^[yY]";
68 | case NOEXPR: return "^[nN]";
69 | case CRNCYSTR: return "$";
70 | default: return 0;
71 | }
72 | }
73 |
74 | char * __nl_langinfo_l( item , locale )
75 | nl_item item ;
76 | __locale_t locale __attribute__((unused)) ;
77 | {
78 | /* TODO: ? */
79 | return nl_langinfo( item ) ;
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/libmy/printf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "dietstdio.h"
24 |
25 | int printf(const char *format,...)
26 | {
27 | int n;
28 | va_list arg_ptr;
29 | va_start(arg_ptr, format);
30 | n=__vfprintf_chk(stdout , 0 , format, arg_ptr);
31 | va_end(arg_ptr);
32 | return n;
33 | }
34 |
--------------------------------------------------------------------------------
/libmy/printf_chk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "dietstdio.h"
24 |
25 | int __printf_chk(
26 | int flag __attribute__((unused)) ,
27 | const char *format ,
28 | ... )
29 | {
30 | int n;
31 | va_list arg_ptr;
32 | va_start(arg_ptr, format);
33 | n=__vfprintf_chk(stdout , 0 , format, arg_ptr);
34 | va_end(arg_ptr);
35 | return n;
36 | }
37 |
--------------------------------------------------------------------------------
/libmy/pthread_mutex.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int pthread_mutex_lock (mutex)
21 | pthread_mutex_t *mutex __attribute__((unused)) ;
22 | {
23 | __fortify_fail( "pthread_mutex_lock()" ) ;
24 | }
25 |
26 | int pthread_mutex_unlock (mutex)
27 | pthread_mutex_t *mutex __attribute__((unused)) ;
28 | {
29 | __fortify_fail( "pthread_mutex_unlock()" ) ;
30 | }
31 |
--------------------------------------------------------------------------------
/libmy/read_chk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | ssize_t
21 | __read_chk (int fd, void *buf, size_t nbytes, size_t buflen)
22 | {
23 | if (nbytes > buflen)
24 | __fortify_fail ("buffer overflow detected");
25 |
26 | return read (fd, buf, nbytes);
27 | }
28 |
--------------------------------------------------------------------------------
/libmy/setlocale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* en premier */
19 |
20 | #include
21 |
22 | char * __setlocale( category , locale )
23 | int category __attribute__((unused)) ;
24 | const char* locale __attribute__((unused)) ;
25 | {
26 | return "C.UTF-8" ;
27 | }
28 |
29 | __typeof (__setlocale) setlocale __attribute__((weak, alias("__setlocale"))) ;
30 |
31 |
--------------------------------------------------------------------------------
/libmy/setvbuf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * setvbuf
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "libmy.h"
24 | #include
25 |
26 |
27 | /**
28 | * setvbuf() : choix du buffering.
29 | * Toutes les fonctions associées aux FILE de libmy commencent
30 | * par un setvbuf( f , NULL , _IONBF , 0 ) pour ne pas utiliser
31 | * de buffer du tout. L'appel est ici ignoré.
32 | */
33 | int
34 | setvbuf( stream , buffer , mode , size )
35 | FILE * stream __attribute__((unused)) ;
36 | char * buffer __attribute__((unused)) ;
37 | int mode __attribute__((unused)) ;
38 | size_t size __attribute__((unused)) ;
39 | {
40 | return 0 ;
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/libmy/single_threaded.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | /* Default value of glibc variable for single-thread optimizations. */
21 | char __libc_single_threaded = 0;
22 |
23 |
--------------------------------------------------------------------------------
/libmy/sleep.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | unsigned int sleep( seconds )
22 | unsigned int seconds ;
23 | {
24 | time_t t = time( NULL ) ;
25 | for(;;) {
26 | time_t tf = time( NULL ) ;
27 | if ( t + (time_t) seconds < tf ) return 0 ;
28 | }
29 | return 0 ;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libmy/sprintf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #define _XOPEN_SOURCE 600
18 | #include "libmy.h"
19 | #include
20 | #include
21 | #include
22 |
23 | #include "dietstdio.h"
24 |
25 | #pragma GCC diagnostic ignored "-Wstringop-overflow"
26 |
27 | int sprintf(char *dest,const char *format,...)
28 | {
29 | int n;
30 | va_list arg_ptr;
31 | va_start(arg_ptr, format);
32 | n=__vsnprintf_chk(dest , (size_t) -1 , 0 , (size_t) -1 , format,arg_ptr);
33 | va_end (arg_ptr);
34 | return n;
35 | }
36 |
--------------------------------------------------------------------------------
/libmy/sprintf_chk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 |
22 | #include "dietstdio.h"
23 |
24 | #pragma GCC diagnostic ignored "-Wstringop-overflow"
25 |
26 | int __sprintf_chk(
27 | char * s ,
28 | int flag __attribute__((unused)) ,
29 | size_t slen __attribute__((unused)) ,
30 | const char * format ,
31 | ... )
32 | {
33 | va_list arg ;
34 | int done ;
35 | va_start( arg , format ) ;
36 | done = __vsnprintf_chk( s , (size_t) -1 , 0 , (size_t) -1 , format , arg ) ;
37 | va_end( arg ) ;
38 | return done ;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/libmy/sscanf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | extern int sscanf( const char * s , const char * format , ... ) ;
18 |
19 | #include "libmy.h"
20 | #include
21 | #include
22 |
23 | #ifdef __sscanf
24 | # undef __sscanf
25 | #endif
26 |
27 | #ifdef vsscanf
28 | # undef vsscanf
29 | #endif
30 |
31 | #ifdef __vsscanf
32 | # undef __vsscanf
33 | #endif
34 |
35 | #ifdef sscanf
36 | # undef sscanf
37 | #endif
38 |
39 | extern int __vsscanf(const char* str, const char* format, va_list arg_ptr) ;
40 |
41 | int __sscanf( const char * s , const char * format , ... )
42 | {
43 | va_list arg ;
44 | int done ;
45 | va_start( arg , format ) ;
46 | done = __vsscanf( s , format , arg ) ;
47 | va_end( arg ) ;
48 | return done ;
49 | }
50 |
51 | __typeof (__sscanf) sscanf __attribute__((weak, alias("__sscanf"))) ;
52 | __typeof (__sscanf) __isoc23_sscanf __attribute__((weak, alias("__sscanf"))) ;
53 |
--------------------------------------------------------------------------------
/libmy/stdio.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | * Entrée sortie FILE de stdio.
17 | * Les trois sont un seul fichier comme glibc
18 | * Le fichier définit également _IO_stdio pour stdin, etc...
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "libmy.h"
24 | #include
25 |
26 |
27 | /**
28 | * Le flux stdin.
29 | */
30 | #ifdef stdin
31 | #undef stdin
32 | #endif
33 | #ifdef _IO_stdin
34 | #undef _IO_stdin
35 | #endif
36 | static struct _IO_FILE
37 | my_stdin = { ._fileno = 0 } ;
38 |
39 | struct _IO_FILE *
40 | stdin = & my_stdin ;
41 |
42 | extern struct _IO_FILE *
43 | _IO_stdin __attribute__(( alias("stdin") )) ;
44 |
45 |
46 | /**
47 | * Le flux stdout.
48 | */
49 | #ifdef stdout
50 | #undef stdout
51 | #endif
52 | #ifdef _IO_stdout
53 | #undef _IO_stdout
54 | #endif
55 | static struct _IO_FILE
56 | my_stdout = { ._fileno = 1 } ;
57 |
58 | struct _IO_FILE *
59 | stdout = & my_stdout ;
60 |
61 | extern struct _IO_FILE *
62 | _IO_stdout __attribute__(( alias("stdout") )) ;
63 |
64 |
65 | /**
66 | * Le flux stderr.
67 | */
68 | #ifdef stderr
69 | #undef stderr
70 | #endif
71 | #ifdef _IO_stderr
72 | #undef _IO_stderr
73 | #endif
74 | static struct _IO_FILE
75 | my_stderr = { ._fileno = 2 } ;
76 |
77 | struct _IO_FILE *
78 | stderr = & my_stderr ;
79 |
80 | extern struct _IO_FILE *
81 | _IO_stderr __attribute__(( alias("stderr") )) ;
82 |
83 |
--------------------------------------------------------------------------------
/libmy/strcmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* fast strcmp -- Copyright (C) 2003 Thomas M. Ogrisegg */
19 | #include
20 | #include "dietfeatures.h"
21 | #include "dietstring.h"
22 |
23 | #ifdef strcmp
24 | # undef strcmp
25 | #endif
26 |
27 | int
28 | strcmp (const char *s1, const char *s2)
29 | {
30 | while (*s1 && *s1 == *s2)
31 | s1++, s2++;
32 | return (*s1 - *s2);
33 | }
34 |
35 | int strcoll(const char *s,const char* t) __attribute__((weak,alias("strcmp")));
36 |
37 | /* fast strcmp -- Copyright (C) 2003 Thomas M. Ogrisegg */
38 | int
39 | strncmp (const char *s1, const char *s2, size_t n)
40 | {
41 | unsigned char c1 = '\0';
42 | unsigned char c2 = '\0';
43 | while (n > 0)
44 | {
45 | c1 = (unsigned char) *s1++;
46 | c2 = (unsigned char) *s2++;
47 | if (c1 == '\0' || c1 != c2)
48 | return c1 - c2;
49 | n--;
50 | }
51 | return c1 - c2;
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/libmy/strcoll.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | int __strcoll_l( s1 , s2 , loc )
22 | const char *s1 ;
23 | const char *s2 ;
24 | __locale_t loc __attribute__((unused)) ;
25 | {
26 | return strcmp( s1 , s2 ) ;
27 | }
28 |
29 | __typeof( __strcoll_l ) strcoll_l __attribute__((weak,alias("__strcoll_l"))) ;
30 |
31 | /*
32 | int strcoll( s1 , s2 )
33 | const char *s1 ;
34 | const char *s2 ;
35 | {
36 | return strcoll_l( s1 , s2 , NULL ) ;
37 | }
38 | */
39 |
40 |
--------------------------------------------------------------------------------
/libmy/strcpy.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 |
19 | /* fast strcpy -- Copyright (C) 2003 Thomas M. Ogrisegg */
20 | #include
21 | #include "dietfeatures.h"
22 | #include "dietstring.h"
23 |
24 | char *
25 | strcpy (char *s1, const char *s2)
26 | {
27 | char *res = s1;
28 | while ((*s1++ = *s2++));
29 | return (res);
30 | }
31 |
--------------------------------------------------------------------------------
/libmy/strdup.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * This file is part of UEFI fdisk.
4 | *
5 | * UEFI fdisk is a port of util-linux fdisk to UEFI/BIOS.
6 | * UEFI fdisk est un portage de util-linux fdisk vers UEFI/BIOS.
7 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
8 | *
9 | * All this work is copyleft Bernard Burette.
10 | * Gauche d'auteur Bernard Burette.
11 | *
12 | * This program is distributed under the terms of the GNU General Public
13 | * License version 2 or more.
14 | * La diffusion de ce code est faite selon les termes de la licence publique
15 | * générale GNU version 2 ou plus.
16 | *
17 | */
18 | #define _GNU_SOURCE
19 | #include "libmy.h"
20 | #include
21 | #include
22 | /* Duplicate S, returning an identical malloc'd string. */
23 | char *
24 | strdup (const char *s)
25 | {
26 | size_t len = strlen (s) + 1;
27 | void *new = malloc (len);
28 | if (new == NULL)
29 | return NULL;
30 | return (char *) memcpy (new, s, len);
31 | }
32 |
--------------------------------------------------------------------------------
/libmy/strerror.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int strerror_r( errnum , buf , len )
21 | int errnum __attribute__((unused)) ;
22 | char * buf __attribute__((unused)) ;
23 | size_t len __attribute__((unused)) ;
24 | {
25 | /* TODO: ? */
26 | __fortify_fail( "strerror_r()" ) ;
27 | /*
28 | return 0 ;
29 | */
30 | }
31 |
32 | static char * my_strerror __attribute__((unused)) ;
33 |
34 | char * strerror( errnum )
35 | int errnum __attribute__((unused)) ;
36 | {
37 | /* TODO: ? */
38 | __fortify_fail( "strerror()" ) ;
39 | /*
40 | char *ret = strerror_r( errnum , NULL , 0 ) ;
41 | int saved_errno ;
42 | if ( ret != NULL ) {
43 | return ret ;
44 | }
45 | saved_errno = errno ;
46 | if ( my_strerror == NULL ) {
47 | my_strerror = malloc( 1024 ) ;
48 | errno = saved_errno ;
49 | if ( my_strerror == NULL ) {
50 | return "Unknown error" ;
51 | }
52 | }
53 | return strerror_r( errnum , my_strerror , 1024 ) ;
54 | */
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/libmy/strftime_l.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | size_t __strftime_l( s , maxsize , format , tp , loc )
22 | char *s __attribute__((unused)) ;
23 | size_t maxsize __attribute__((unused)) ;
24 | const char *format __attribute__((unused)) ;
25 | const struct tm *tp __attribute__((unused)) ;
26 | __locale_t loc __attribute__((unused)) ;
27 | {
28 | /* TODO: ? */
29 | __fortify_fail( "__strftime_l()" ) ;
30 | }
31 |
32 | __typeof (__strftime_l) strftime_l __attribute__((weak, alias("__strftime_l"))) ;
33 |
34 |
--------------------------------------------------------------------------------
/libmy/strlen.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include "dietfeatures.h"
20 | #include
21 |
22 | size_t strlen(const char *s) {
23 | register size_t i;
24 | for (i=0; *s; ++s) ++i;
25 | return i;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/strtod.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | void __strtod_l( nptr , endptr , loc )
21 | const char * nptr __attribute__((unused)) ;
22 | char** endptr __attribute__((unused)) ;
23 | __locale_t loc __attribute__((unused)) ;
24 | {
25 | /* TODO: ? */
26 | __fortify_fail( "__strtod_l()" ) ;
27 | /*
28 | return 0 ;
29 | */
30 | }
31 |
32 | __typeof (__strtod_l) strtod_l __attribute__((weak, alias("__strtod_l"))) ;
33 |
34 | __typeof (__strtod_l) strtod __attribute__((weak, alias("__strtod_l"))) ;
35 |
36 |
--------------------------------------------------------------------------------
/libmy/strtof.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | void __strtof_l( nptr , endptr , loc )
21 | const char * nptr __attribute__((unused)) ;
22 | char** endptr __attribute__((unused)) ;
23 | __locale_t loc __attribute__((unused)) ;
24 | {
25 | /* TODO: ? */
26 | __fortify_fail( "__strtof_l()" ) ;
27 | /*
28 | return 0 ;
29 | */
30 | }
31 |
32 | __typeof (__strtof_l) strtof_l __attribute__((weak, alias("__strtof_l"))) ;
33 |
34 | __typeof (__strtof_l) strtof __attribute__((weak, alias("__strtof_l"))) ;
35 |
36 |
--------------------------------------------------------------------------------
/libmy/strtol.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "dietfeatures.h"
19 | #undef __USE_EXTERN_INLINES
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #if __WORDSIZE == 64
26 | #define ABS_LONG_MIN 9223372036854775808UL
27 | #else
28 | #define ABS_LONG_MIN 2147483648UL
29 | #endif
30 |
31 | /* __ctype_b_loc returns the address in the image file which
32 | is not the address in memory: crash guaranteed we should
33 | do something with the relocations. Fixed since version 0.1 */
34 | #ifdef isspace
35 | # undef isspace
36 | #endif
37 | #define isspace( c ) ( ( c ) <= ' ' )
38 | #ifdef isalnum
39 | # undef isalnum
40 | #endif
41 | #define isalnum( c ) ( ( ( c ) >= '0' && ( c ) <= '9' ) || \
42 | ( ( c ) >= 'A' && ( c ) <= 'Z' ) || \
43 | ( ( c ) >= 'a' && ( c ) <= 'z' ) )
44 |
45 | long int strtol(const char *nptr, char **endptr, int base)
46 | {
47 | int neg=0;
48 | unsigned long int v;
49 | const char*orig=nptr;
50 |
51 | while(isspace(*nptr)) nptr++;
52 |
53 | if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; }
54 | v=strtoul(nptr,endptr,base);
55 | if (endptr && *endptr==nptr) *endptr=(char *)orig;
56 | if (v>=ABS_LONG_MIN) {
57 | if (v==ABS_LONG_MIN && neg) {
58 | errno=0;
59 | return v;
60 | }
61 | errno=ERANGE;
62 | return (neg?LONG_MIN:LONG_MAX);
63 | }
64 | return (neg?-v:v);
65 | }
66 |
--------------------------------------------------------------------------------
/libmy/strtold.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | void __strtold_l( nptr , endptr , loc )
21 | const char * nptr __attribute__((unused)) ;
22 | char** endptr __attribute__((unused)) ;
23 | __locale_t loc __attribute__((unused)) ;
24 | {
25 | /* TODO: ? */
26 | __fortify_fail( "__strtod_l()" ) ;
27 | /*
28 | return 0 ;
29 | */
30 | }
31 |
32 | __typeof (__strtold_l) strtold_l __attribute__((weak, alias("__strtold_l"))) ;
33 |
34 | __typeof (__strtold_l) strtold __attribute__((weak, alias("__strtold_l"))) ;
35 |
36 |
--------------------------------------------------------------------------------
/libmy/strtoul.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* first */
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | /*
29 | *
30 | */
31 |
32 |
33 | #ifdef isspace
34 | # undef isspace
35 | #endif
36 | #define isspace( c ) ( c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v' )
37 | #ifdef isalnum
38 | # undef isalnum
39 | #endif
40 | #define isalnum( c ) ( ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ) )
41 | #ifdef isxdigit
42 | # undef isxdigit
43 | #endif
44 | #define isxdigit( c ) ( ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'F' ) || ( c >= 'a' && c <= 'f' ) )
45 |
46 | unsigned long int
47 | __attribute__((weak))
48 | __strtoul(const char *ptr, char **endptr, int base)
49 | {
50 | int neg = 0, overflow = 0;
51 | unsigned long int v=0;
52 | const char* orig;
53 | const char* nptr=ptr;
54 |
55 | while(isspace(*nptr)) ++nptr;
56 |
57 | if (*nptr == '-') { neg=1; nptr++; }
58 | else if (*nptr == '+') ++nptr;
59 | orig=nptr;
60 | if (base==16 && nptr[0]=='0') goto skip0x;
61 | if (base) {
62 | register unsigned int b=base-2;
63 | if ((b>34)) { errno=EINVAL; return 0; }
64 | } else {
65 | if (*nptr=='0') {
66 | base=8;
67 | skip0x:
68 | if ((nptr[1]=='x'||nptr[1]=='X') && isxdigit(nptr[2])) {
69 | nptr+=2;
70 | base=16;
71 | }
72 | } else
73 | base=10;
74 | }
75 | while((*nptr)) {
76 | register unsigned char c=*nptr;
77 | c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff);
78 | if ((c>=base)) break; /* out of base */
79 | {
80 | register unsigned long x=(v&0xff)*base+c;
81 | register unsigned long w=(v>>8)*base+(x>>8);
82 | if (w>(ULONG_MAX>>8)) overflow=1;
83 | v=(w<<8)+(x&0xff);
84 | }
85 | ++nptr;
86 | }
87 | if ((nptr==orig)) { /* no conversion done */
88 | nptr=ptr;
89 | errno=EINVAL;
90 | v=0;
91 | }
92 | if (endptr) *endptr=(char *)nptr;
93 | if (overflow) {
94 | errno=ERANGE;
95 | return ULONG_MAX;
96 | }
97 | return (neg?-v:v);
98 | }
99 |
100 | __typeof (__strtoul) strtoul __attribute__((weak, alias("__strtoul"))) ;
101 | __typeof (__strtoul) __strtoul_internal __attribute__((weak, alias("__strtoul"))) ;
102 |
103 |
--------------------------------------------------------------------------------
/libmy/strxfrm.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | size_t __strxfrm_l( dest , src , n , loc )
22 | char *dest __attribute__((unused)) ;
23 | const char *src __attribute__((unused)) ;
24 | size_t n __attribute__((unused)) ;
25 | __locale_t loc __attribute__((unused)) ;
26 | {
27 | /* TODO: ? */
28 | __fortify_fail( "__strxfrm_l()" ) ;
29 | /*
30 | size_t m = strlen( src ) ;
31 | if ( m < n ) m = n ;
32 | strncpy( dest , src , n ) ;
33 | return m ;
34 | */
35 | }
36 |
37 | __typeof (__strxfrm_l) strxfrm_l __attribute__((weak, alias("__strxfrm_l"))) ;
38 |
39 | /*
40 | size_t strxfrm( dest , src , n )
41 | char *dest ;
42 | const char *src ;
43 | size_t n ;
44 | {
45 | return strxfrm_l( dest , src , n , NULL ) ;
46 | }
47 | */
48 |
49 |
--------------------------------------------------------------------------------
/libmy/syscall.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | long int syscall(
22 | long int __sysno __attribute__((unused)) ,
23 | ... )
24 | {
25 | return 0 ;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/textdomain.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | char * textdomain( domainname )
21 | const char * domainname __attribute__((unused)) ;
22 | {
23 | /* TODO: ? */
24 | __fortify_fail( "textdomain()" ) ;
25 | /*
26 | return domainname ;
27 | */
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/libmy/tls.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | /* Definition for thread-local data handling. Generic version.
19 | Copyright (C) 2002-2013 Free Software Foundation, Inc.
20 | This file is part of the GNU C Library.
21 |
22 | The GNU C Library is free software; you can redistribute it and/or
23 | modify it under the terms of the GNU Lesser General Public
24 | License as published by the Free Software Foundation; either
25 | version 2.1 of the License, or (at your option) any later version.
26 |
27 | The GNU C Library is distributed in the hope that it will be useful,
28 | but WITHOUT ANY WARRANTY; without even the implied warranty of
29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 | Lesser General Public License for more details.
31 |
32 | You should have received a copy of the GNU Lesser General Public
33 | License along with the GNU C Library; if not, see
34 | . */
35 |
36 | /* An architecture-specific version of this file has to defined a
37 | number of symbols:
38 |
39 | TLS_TCB_AT_TP or TLS_DTV_AT_TP
40 |
41 | The presence of one of these symbols signals which variant of
42 | the TLS ABI is used. There are in the moment two variants
43 | available:
44 |
45 | * the thread pointer points to a thread control block
46 |
47 | * the thread pointer points to the dynamic thread vector
48 |
49 |
50 | TLS_TCB_SIZE
51 |
52 | This is the size of the thread control block structure. How
53 | this is actually defined depends on the ABI. The thread control
54 | block could be internal descriptor of the thread library or
55 | just a data structure which allows finding the DTV.
56 |
57 | TLS_INIT_TCB_SIZE
58 |
59 | Similarly, but this value is only used at startup and in the
60 | dynamic linker itself. There are no threads in use at that time.
61 |
62 |
63 | TLS_TCB_ALIGN
64 |
65 | Alignment requirements for the TCB structure.
66 |
67 | TLS_INIT_TCB_ALIGN
68 |
69 | Similarly, but for the structure used at startup time.
70 |
71 |
72 | INSTALL_DTV(tcb, init_dtv)
73 |
74 | This macro must install the given initial DTV into the thread control
75 | block TCB. The normal runtime functionality must then be able to
76 | use the value.
77 |
78 |
79 | TLS_INIT_TP(tcb, firstcall)
80 |
81 | This macro must initialize the thread pointer to enable normal TLS
82 | operation. The first parameter is a pointer to the thread control
83 | block. The second parameter specifies whether this is the first
84 | call for the TCB. ld.so calls this macro more than once.
85 |
86 |
87 | THREAD_DTV()
88 |
89 | This macro returns the address of the DTV of the current thread.
90 | This normally is done using the thread register which points
91 | to the dtv or the TCB (from which the DTV can found).
92 | */
93 |
--------------------------------------------------------------------------------
/libmy/tolower.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #ifdef tolower
21 | # undef tolower
22 | #endif
23 |
24 | int tolower(int ch) {
25 | if ( (unsigned int)(ch - 'A') < 26u )
26 | ch += 'a' - 'A';
27 | return ch;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/libmy/toupper.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | #ifdef toupper
21 | # undef toupper
22 | #endif
23 |
24 | int toupper(int ch) {
25 | if ( (unsigned int)(ch - 'a') < 26u )
26 | ch += 'A' - 'a';
27 | return ch;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/libmy/towlower.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | wint_t __towlower_l( wc , locale )
22 | wint_t wc ;
23 | __locale_t locale __attribute__((unused)) ;
24 | {
25 | if ( wc >= 'A' && wc <='Z' ) {
26 | wc -= 'A' ;
27 | wc += 'a' ;
28 | }
29 | return wc ;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libmy/towupper.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | wint_t __towupper_l( wc , locale )
22 | wint_t wc ;
23 | __locale_t locale __attribute__((unused)) ;
24 | {
25 | if ( wc >= 'a' && wc <='z' ) {
26 | wc -= 'a' ;
27 | wc += 'A' ;
28 | }
29 | return wc ;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libmy/uselocale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "ctype.h"
21 | #pragma GCC diagnostic ignored "-Waddress"
22 | /* uselocale -- fetch and set the current per-thread locale
23 | Copyright (C) 2002-2013 Free Software Foundation, Inc.
24 | This file is part of the GNU C Library.
25 |
26 | The GNU C Library is free software; you can redistribute it and/or
27 | modify it under the terms of the GNU Lesser General Public
28 | License as published by the Free Software Foundation; either
29 | version 2.1 of the License, or (at your option) any later version.
30 |
31 | The GNU C Library is distributed in the hope that it will be useful,
32 | but WITHOUT ANY WARRANTY; without even the implied warranty of
33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 | Lesser General Public License for more details.
35 |
36 | You should have received a copy of the GNU Lesser General Public
37 | License along with the GNU C Library; if not, see
38 | . */
39 |
40 | #include
41 | #include "localeinfo.h"
42 | #include
43 |
44 | extern __thread __locale_t _NL_CURRENT_LOCALE ;
45 |
46 | /* Switch the current thread's locale to DATASET.
47 | If DATASET is null, instead just return the current setting.
48 | The special value LC_GLOBAL_LOCALE is the initial setting
49 | for all threads, and means the thread uses the global
50 | setting controlled by `setlocale'. */
51 | locale_t
52 | __uselocale (locale_t newloc)
53 | {
54 |
55 |
56 |
57 | locale_t oldloc = _NL_CURRENT_LOCALE;
58 |
59 | if (newloc != NULL)
60 | {
61 | const locale_t locobj
62 | = newloc == LC_GLOBAL_LOCALE ? &_nl_global_locale : newloc;
63 | __libc_tsd_set (__locale_t, LOCALE, locobj);
64 |
65 | #ifdef NL_CURRENT_INDIRECT
66 | /* Now we must update all the per-category thread-local variables to
67 | point into the new current locale for this thread. The magic
68 | symbols _nl_current_LC_FOO_used are defined to meaningless values
69 | if _nl_current_LC_FOO was linked in. By using weak references to
70 | both symbols and testing the address of _nl_current_LC_FOO_used,
71 | we can avoid accessing the _nl_current_LC_FOO thread-local
72 | variable at all when no code referring to it was linked in. We
73 | need the special bogus symbol because while TLS symbols can be
74 | weak, there is no reasonable way to test for the default-zero
75 | value as with a heap symbol (taking the address would just use
76 | some bogus offset from our thread pointer). */
77 |
78 | # define DEFINE_CATEGORY(category, category_name, items, a) \
79 | { \
80 | extern char _nl_current_##category##_used; \
81 | weak_extern (_nl_current_##category##_used) \
82 | weak_extern (_nl_current_##category) \
83 | if (&_nl_current_##category##_used != 0) \
84 | _nl_current_##category = &locobj->__locales[category]; \
85 | }
86 | # include "categories.def"
87 | # undef DEFINE_CATEGORY
88 | #endif
89 |
90 | /* Update the special tsd cache of some locale data. */
91 | __libc_tsd_set (const uint16_t *, CTYPE_B, (void *) locobj->__ctype_b);
92 | __libc_tsd_set (const int32_t *, CTYPE_TOLOWER,
93 | (void *) locobj->__ctype_tolower);
94 | __libc_tsd_set (const int32_t *, CTYPE_TOUPPER,
95 | (void *) locobj->__ctype_toupper);
96 | }
97 |
98 |
99 |
100 | return oldloc == &_nl_global_locale ? LC_GLOBAL_LOCALE : oldloc;
101 | }
102 | libc_hidden_def (__uselocale)
103 | __typeof ( __uselocale ) uselocale __attribute__(( weak , alias( "__uselocale" )) ) ;
104 |
--------------------------------------------------------------------------------
/libmy/vfprintf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "dietstdio.h"
24 |
25 | static int __fwrite(void*ptr, size_t nmemb, FILE* f) {
26 | return fwrite(ptr,1,nmemb,f);
27 | }
28 |
29 | int vfprintf(FILE *stream, const char *format, va_list arg_ptr)
30 | {
31 | struct arg_printf ap = { stream, (int(*)(void*,size_t,void*)) __fwrite };
32 | return __v_printf(&ap,format,arg_ptr);
33 | }
34 |
--------------------------------------------------------------------------------
/libmy/vfprintf_chk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "dietstdio.h"
24 |
25 | static int __fwrite(void*ptr, size_t nmemb, FILE* f) {
26 | return fwrite(ptr,1,nmemb,f);
27 | }
28 |
29 | int __vfprintf_chk(
30 | FILE * stream ,
31 | int flag __attribute__((unused)) ,
32 | const char *format ,
33 | va_list arg_ptr )
34 | {
35 | struct arg_printf ap = { stream, (int(*)(void*,size_t,void*)) __fwrite };
36 | return __v_printf(&ap,format,arg_ptr);
37 | }
38 |
--------------------------------------------------------------------------------
/libmy/vsnprintf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include "dietstdio.h"
25 |
26 | struct str_data {
27 | char* str;
28 | size_t len;
29 | size_t size;
30 | };
31 |
32 | static int swrite(void*ptr, size_t nmemb, struct str_data* sd) {
33 | size_t tmp=sd->size-sd->len;
34 | if (tmp>0) {
35 | size_t len=nmemb;
36 | if (len>tmp) len=tmp;
37 | if (sd->str) {
38 | memcpy(sd->str+sd->len,ptr,len);
39 | sd->str[sd->len+len]=0;
40 | }
41 | sd->len+=len;
42 | }
43 | return nmemb;
44 | }
45 |
46 | int vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr) {
47 | int n;
48 | struct str_data sd = { str, 0, size?size-1:0 };
49 | struct arg_printf ap = { &sd, (int(*)(void*,size_t,void*)) swrite };
50 | n=__v_printf(&ap,format,arg_ptr);
51 | if (str && size && n>=0) {
52 | if (size!=(size_t)-1 && ((size_t)n>=size)) str[size-1]=0;
53 | else str[n]=0;
54 | }
55 | return n;
56 | }
57 |
--------------------------------------------------------------------------------
/libmy/vsnprintf_chk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include "dietstdio.h"
25 |
26 | struct str_data {
27 | char* str;
28 | size_t len;
29 | size_t size;
30 | };
31 |
32 | static int swrite(void*ptr, size_t nmemb, struct str_data* sd) {
33 | size_t tmp=sd->size-sd->len;
34 | if (tmp>0) {
35 | size_t len=nmemb;
36 | if (len>tmp) len=tmp;
37 | if (sd->str) {
38 | memcpy(sd->str+sd->len,ptr,len);
39 | sd->str[sd->len+len]=0;
40 | }
41 | sd->len+=len;
42 | }
43 | return nmemb;
44 | }
45 |
46 | int __vsnprintf_chk(
47 | char * str ,
48 | size_t size ,
49 | int flag __attribute__((unused)) ,
50 | size_t real_size __attribute__((unused)) ,
51 | const char * format ,
52 | va_list arg_ptr )
53 | {
54 | int n;
55 | struct str_data sd = { str, 0, size?size-1:0 };
56 | struct arg_printf ap = { &sd, (int(*)(void*,size_t,void*)) swrite };
57 | n=__v_printf(&ap,format,arg_ptr);
58 | if (str && size && n>=0) {
59 | if (size!=(size_t)-1 && ((size_t)n>=size)) str[size-1]=0;
60 | else str[n]=0;
61 | }
62 | return n;
63 | }
64 |
--------------------------------------------------------------------------------
/libmy/vsscanf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #define _GNU_SOURCE 1
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | #include "dietstdio.h"
25 |
26 | struct str_data {
27 | unsigned char* str;
28 | };
29 |
30 | static int sgetc(struct str_data* sd) {
31 | register unsigned int ret = *(sd->str++);
32 | return (ret)?(int)ret:-1;
33 | }
34 |
35 | static int sputc(int c, struct str_data* sd) {
36 | return (*(--sd->str)==c)?c:-1;
37 | }
38 |
39 | #ifdef __vsscanf
40 | # undef __vsscanf
41 | #endif
42 |
43 | int __vsscanf(const char* str, const char* format, va_list arg_ptr)
44 | {
45 | struct str_data fdat = { (unsigned char*)str };
46 | struct arg_scanf farg = { (void*)&fdat, (int(*)(void*))sgetc, (int(*)(int,void*))sputc };
47 | return __v_scanf(&farg,format,arg_ptr);
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/libmy/wcrtomb.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t wcrtomb(
21 | char * s __attribute__((unused)) ,
22 | wchar_t wc __attribute__((unused)) ,
23 | mbstate_t * ps __attribute__((unused))
24 | )
25 | {
26 | /* TODO: ? */
27 | __fortify_fail( "wcrtomb()" ) ;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/libmy/wcscmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int wcscmp( s1 , s2 )
21 | const wchar_t * s1 __attribute__((unused)) ;
22 | const wchar_t * s2 __attribute__((unused)) ;
23 | {
24 | __fortify_fail( "wcscmp()" ) ;
25 | /*
26 | wint_t c1 , c2 ;
27 | do {
28 | c1 = (wint_t) *s1 ;
29 | c2 = (wint_t) *s2 ;
30 | if ( c1 == L'\0' ) return c1 - c2 ;
31 | s1 ++ ;
32 | s2 ++ ;
33 | } while ( c1 == c2 ) ;
34 | return c1 - c2;
35 | */
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/libmy/wcscoll.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | int __wcscoll_l( s1 , s2 , loc )
22 | const wchar_t *s1 ;
23 | const wchar_t *s2 ;
24 | __locale_t loc __attribute__((unused)) ;
25 | {
26 | return wcscmp( s1 , s2 ) ;
27 | }
28 |
29 | __typeof (__wcscoll_l) wcscoll_l __attribute__((weak, alias("__wcscoll_l"))) ;
30 |
31 | int wcscoll( s1 , s2 )
32 | const wchar_t *s1 ;
33 | const wchar_t *s2 ;
34 | {
35 | return wcscoll_l( s1 , s2 , NULL ) ;
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/libmy/wcsftime_l.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | size_t __wcsftime_l( s , maxsize , format , tp , loc )
22 | char *s __attribute__((unused)) ;
23 | size_t maxsize __attribute__((unused)) ;
24 | const char *format __attribute__((unused)) ;
25 | const struct tm *tp __attribute__((unused)) ;
26 | __locale_t loc __attribute__((unused)) ;
27 | {
28 | /* TODO: ? */
29 | __fortify_fail( "__wcsftime_l()" ) ;
30 | }
31 |
32 | __typeof (__wcsftime_l) wcsftime_l __attribute__((weak, alias("__wcsftime_l"))) ;
33 |
34 |
--------------------------------------------------------------------------------
/libmy/wcslen.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t wcslen( str )
21 | const wchar_t * str __attribute__((unused)) ;
22 | {
23 | __fortify_fail( "wcslen()" ) ;
24 | /*
25 | const wchar_t * s ;
26 | for ( s = str ; *s ; ++ s ) { }
27 | return s - str ;
28 | */
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/libmy/wcsnrtombs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | size_t wcsnrtombs( dst , src , nwc , len , ps )
21 | char * dst __attribute__((unused)) ;
22 | const wchar_t ** src __attribute__((unused)) ;
23 | size_t nwc __attribute__((unused)) ;
24 | size_t len __attribute__((unused)) ;
25 | mbstate_t * ps __attribute__((unused)) ;
26 | {
27 | /* TODO: ? */
28 | __fortify_fail( "wcsnrtombs()" ) ;
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/libmy/wcsxfrm.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | size_t __wcsxfrm_l( dest , src , n , loc )
22 | wchar_t *dest __attribute__((unused)) ;
23 | const wchar_t *src __attribute__((unused)) ;
24 | size_t n __attribute__((unused)) ;
25 | __locale_t loc __attribute__((unused)) ;
26 | {
27 | /* TODO: ? */
28 | __fortify_fail( "__wcsxfrm_l()" ) ;
29 | /*
30 | size_t m = wcslen( src ) ;
31 | if ( m < n ) m = n ;
32 | wcsncpy( dest , src , n ) ;
33 | return m ;
34 | */
35 | }
36 |
37 | __typeof( __wcsxfrm_l ) wcsxfrm_l __attribute__((weak,alias("__wcsxfrm_l"))) ;
38 |
39 | size_t wcsxfrm( dest , src , n )
40 | wchar_t *dest ;
41 | const wchar_t *src ;
42 | size_t n ;
43 | {
44 | return wcsxfrm_l( dest , src , n , NULL ) ;
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/libmy/wctob.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 |
21 | int wctob( c )
22 | wint_t c ;
23 | {
24 | if ( c == 0 || ( c > 0 && c <= 0x7f ) ) return (int) c ;
25 | return EOF ;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/libmy/wctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 |
22 | wctype_t __wctype_l( property , locale )
23 | const char *property __attribute__((unused)) ;
24 | __locale_t locale __attribute__((unused)) ;
25 | {
26 | /* TODO: ? */
27 | /*
28 | __fortify_fail( "__wctype_l()" ) ;
29 | */
30 | return 0 ;
31 | }
32 |
33 | __typeof( __wctype_l ) wctype_l __attribute__((weak,alias("__wctype_l"))) ;
34 |
35 | wctype_t wctype( property )
36 | const char *property __attribute__((unused)) ;
37 | {
38 | return wctype_l( property , NULL ) ;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/libmy/wmemchr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) ;
21 |
22 | wchar_t * wmemchr(
23 | const wchar_t * s __attribute__((unused)) ,
24 | wchar_t c __attribute__((unused)) ,
25 | size_t n __attribute__((unused))
26 | )
27 | {
28 | __fortify_fail( "wmemchr()" ) ;
29 | /*
30 | size_t i ;
31 | for ( i = 0 ; i < n ; i++ ) {
32 | if ( * s == c ) {
33 | return (wchar_t *) s ;
34 | }
35 | s ++ ;
36 | }
37 | return NULL ;
38 | */
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/libmy/wmemcmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | int wmemcmp( s1 , s2 , n )
21 | const wchar_t * s1 __attribute__((unused)) ;
22 | const wchar_t * s2 __attribute__((unused)) ;
23 | size_t n __attribute__((unused)) ;
24 | {
25 | __fortify_fail( "wmemcmp()" ) ;
26 | /*
27 | size_t i ;
28 | for ( i = 0 ; i < n ; i ++ ) {
29 | if ( *s1 != *s2 ) {
30 | return *s1 > *s2 ? 1 : -1 ;
31 | }
32 | s1 ++ ;
33 | s2 ++ ;
34 | }
35 | return 0 ;
36 | */
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/libmy/wmemcpy.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | wchar_t * wmemcpy( dest , src , n )
21 | wchar_t * dest __attribute__((unused)) ;
22 | const wchar_t * src __attribute__((unused)) ;
23 | size_t n __attribute__((unused)) ;
24 | {
25 | __fortify_fail( "wmemcpy()" ) ;
26 | /*
27 | return (wchar_t *) memcpy( dest , src , n * sizeof( wchar_t ) ) ;
28 | */
29 | }
30 |
31 | wchar_t * __wmemcpy_chk (s1, s2, n, ns1)
32 | wchar_t *s1 __attribute__((unused)) ;
33 | const wchar_t *s2 __attribute__((unused)) ;
34 | size_t n __attribute__((unused)) ;
35 | size_t ns1 __attribute__((unused)) ;
36 | {
37 | __fortify_fail( "__wmemcpy_chk()" ) ;
38 | }
39 |
--------------------------------------------------------------------------------
/libmy/wmemmove.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | wchar_t * wmemmove( dest , src , n )
21 | wchar_t * dest __attribute__((unused)) ;
22 | const wchar_t * src __attribute__((unused)) ;
23 | size_t n __attribute__((unused)) ;
24 | {
25 | __fortify_fail( "wmemmove()" ) ;
26 | /*
27 | return (wchar_t *) memmove( dest , src , n * sizeof( wchar_t ) ) ;
28 | */
29 | }
30 |
31 | wchar_t * __wmemmove_chk (s1, s2, n, ns1)
32 | wchar_t *s1 __attribute__((unused)) ;
33 | const wchar_t *s2 __attribute__((unused)) ;
34 | size_t n __attribute__((unused)) ;
35 | size_t ns1 __attribute__((unused)) ;
36 | {
37 | __fortify_fail( "__wmemmove_chk()" ) ;
38 | }
39 |
--------------------------------------------------------------------------------
/libmy/wmemset.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * Original work is copyleft Bernard Burette.
11 | * Modifications are copyleft Joseph Zeller.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 |
20 | wchar_t * wmemset(s, c, n)
21 | wchar_t * s __attribute__((unused)) ;
22 | wchar_t c __attribute__((unused)) ;
23 | size_t n __attribute__((unused)) ;
24 | {
25 | __fortify_fail( "wmemset()" ) ;
26 | /*
27 | size_t i;
28 | wchar_t * p ;
29 | p = s ;
30 | for ( i = 0 ; i < n ; i ++ ) {
31 | *p = c ;
32 | p ++ ;
33 | }
34 | return s ;
35 | */
36 | }
37 |
38 | wchar_t * __wmemset_chk (s, c, n, dstlen)
39 | wchar_t *s __attribute__((unused)) ;
40 | wchar_t c __attribute__((unused)) ;
41 | size_t n __attribute__((unused)) ;
42 | size_t dstlen __attribute__((unused)) ;
43 | {
44 | __fortify_fail( "__wmemset_chk()" ) ;
45 | }
46 |
--------------------------------------------------------------------------------
/libmy/writev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include
19 | #include
20 | #include
21 |
22 | ssize_t writev( fd , iov , iovcnt )
23 | int fd ;
24 | const struct iovec * iov ;
25 | int iovcnt ;
26 | {
27 | int count ;
28 | ssize_t total = 0 ;
29 | for ( count = 0 ; count < iovcnt ; count ++ ) {
30 | const struct iovec v = iov[ count ] ;
31 | ssize_t l = write( fd , v.iov_base , v.iov_len ) ;
32 | if ( l < 0 ) return l ;
33 | total += l ;
34 | if ( (size_t) l != v.iov_len ) {
35 | break ;
36 | }
37 | }
38 | return total ;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/libmy/xlocale.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | * Ce fichier est récupéré soit de "GNU libc" soit de "dietlibc"
8 | * soit encore il a été créé de toutes pièces.
9 | *
10 | * All this work is copyleft Bernard Burette.
11 | * Gauche d'auteur Bernard Burette.
12 | *
13 | * This program is distributed under the terms of the GNU GPL version 2.
14 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
15 | */
16 |
17 | #include "libmy.h"
18 | #include "libc-tsd.h"
19 | #include "locale.h"
20 | #include "localeinfo.h"
21 | #include "ctype.h"
22 | /* C locale object.
23 | Copyright (C) 2001-2013 Free Software Foundation, Inc.
24 | This file is part of the GNU C Library.
25 | Contributed by Ulrich Drepper , 2001.
26 |
27 | The GNU C Library is free software; you can redistribute it and/or
28 | modify it under the terms of the GNU Lesser General Public
29 | License as published by the Free Software Foundation; either
30 | version 2.1 of the License, or (at your option) any later version.
31 |
32 | The GNU C Library is distributed in the hope that it will be useful,
33 | but WITHOUT ANY WARRANTY; without even the implied warranty of
34 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 | Lesser General Public License for more details.
36 |
37 | You should have received a copy of the GNU Lesser General Public
38 | License along with the GNU C Library; if not, see
39 | . */
40 |
41 | #include
42 | #include "localeinfo.h"
43 |
44 | #define DEFINE_CATEGORY(category, category_name, items, a) \
45 | extern struct __locale_data _nl_C_##category;
46 | #include "categories.def"
47 | #undef DEFINE_CATEGORY
48 |
49 | /* Defined in locale/C-ctype.c. */
50 | extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
51 | extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
52 | extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
53 |
54 |
55 | const struct __locale_struct _nl_C_locobj attribute_hidden =
56 | {
57 | .__locales =
58 | {
59 | #define DEFINE_CATEGORY(category, category_name, items, a) \
60 | [category] = &_nl_C_##category,
61 | #include "categories.def"
62 | #undef DEFINE_CATEGORY
63 | },
64 | .__names =
65 | {
66 | [LC_ALL] = _nl_C_name,
67 | #define DEFINE_CATEGORY(category, category_name, items, a) \
68 | [category] = _nl_C_name,
69 | #include "categories.def"
70 | #undef DEFINE_CATEGORY
71 | },
72 | .__ctype_b = (const unsigned short int *) _nl_C_LC_CTYPE_class + 128,
73 | .__ctype_tolower = (const int *) _nl_C_LC_CTYPE_tolower + 128,
74 | .__ctype_toupper = (const int *) _nl_C_LC_CTYPE_toupper + 128
75 | };
76 |
--------------------------------------------------------------------------------
/start-ia32.S:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | #error 32 bits builds are not available
16 |
17 |
--------------------------------------------------------------------------------
/start-x86_64.S:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * Original work is copyleft Bernard Burette.
9 | * Modifications are copyleft Joseph Zeller.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * start-x86_64.S - UEFI startup code for x86_64 architecture.
18 | *
19 | * This module contains the exported _start symbol, the entry
20 | * point of the UEFI image (program).
21 | *
22 | * This module also provides a fake .reloc section, because
23 | * some UEFI loaders need that to detect a program.
24 | *
25 | */
26 |
27 |
28 | //
29 | // Startup code.
30 | // Entry point of program given to "ld" is "_start" in Makefile.
31 | // It first processes the ELF relocation information (because the UEFI loader
32 | // will not have loaded this program at the VMA specified in the file (use
33 | // "objdump -h" to see those VMAs) and we do not use the .reloc section
34 | // because it is defined in µ$ crap and we would have to build it manually.
35 | // It then calls the efi_main() function using x86_64 ABI (arguments in %rdi
36 | // and %rsi registers.
37 | // Also note that since UEFI uses µ$ 64 bits ABI to call this entry point
38 | // the two arguments from the UEFI loader are received here in %rcx and %rdx
39 | // registers.
40 | // This file also uses external symbol _DYNAMIC automatically defined by the
41 | // linker.
42 | //
43 | .section .text.startup, "ax"
44 |
45 | .global _start
46 | _start:
47 |
48 | // make room in the stack
49 | subq $8 , %rsp
50 | // 1st arg (MS ABI %rcx) is ImageHandle
51 | pushq %rcx
52 | // 2nd arg (MS ABI %rdx) is SystemTable
53 | pushq %rdx
54 |
55 | // address of variable UEFI_ImageHandle
56 | lea UEFI_ImageHandle(%rip) , %rdi
57 | // save value of 1st arg in this location
58 | mov %rcx , (%rdi)
59 | // address of variable ST - from GNU EFI library
60 | lea ST(%rip) , %rdi
61 | // save value of 2nd arg in this location
62 | mov %rdx , (%rdi)
63 |
64 | // initialze FPU (will be needed later)
65 | fninit
66 |
67 | // VMA=0 adjusted with %rip to real loaded address
68 | lea ImageBase(%rip) , %rdi
69 | // VMA of .dynamic section adjusted with %rip to real loaded address
70 | lea _DYNAMIC(%rip) , %rsi
71 |
72 | // call with 3 args (x86_64 ABI %rdi, %rsi, %rdx)
73 | call _relocate@PLT
74 |
75 | // call with no args
76 | call _call_init@PLT
77 |
78 | // get SystemTable (pushed to stack by code above)
79 | popq %rsi
80 | // get ImageHandle (pushed to stack by code above)
81 | popq %rdi
82 | // call with 2 args (x86_64 ABI %rdi, %rsi)
83 | call efi_main@PLT
84 |
85 | // use return value for first arg (exit status)
86 | mov %rax , %rdi
87 | // call exit() function with 1 arg (x86_64 ABI %rdi)
88 | // instead of returning
89 | call exit@PLT
90 |
91 | // if we ever return from exit()
92 | addq $8 , %rsp
93 | ret
94 |
95 |
96 | //
97 | // Une entrée .reloc bidon pour faire plaisir au loader EFI
98 | //
99 | .section .reloc, "al"
100 |
101 | .long 0/*VirtualAddress*/
102 | .long 10/*SymbolTableIndex*/
103 | .word ( 0/*do nothing*/ << 12 ) + 0/*fixup*/
104 |
105 |
106 | //
107 | // Les variables UEFI_ImageHandle et ST
108 | //
109 | .bss
110 |
111 | .global UEFI_ImageHandle
112 | .comm UEFI_ImageHandle,8,8
113 | .global ST
114 | .comm ST,8,8
115 |
116 | .section .note.GNU-stack,"",%progbits
117 |
--------------------------------------------------------------------------------
/thread.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en février 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Gestion mulithread.
18 | * La librairie libstdc++ s'attend à un environnement habituel
19 | * dans lequel le multithread est possible, mais en UEFI ce
20 | * n'est pas le cas. Toutefois les fonctions dans ce modules sont
21 | * appelées via le mode @PLT et si elles ne sont définies nulle
22 | * part, le linker laisse la gestion via la GLOBAL_OFFSET_TABLE
23 | * ce qui fera crasher le programme.
24 | * Rechercher GOT / PLT sur Internet pour plus d'explication.
25 | *
26 | */
27 |
28 |
29 | /* en premier */
30 | #include "uefi.h"
31 | #include "debug.h"
32 |
33 | #include
34 |
35 |
36 | /**
37 | * pthread_once() : appelle une fonction une seule fois.
38 | */
39 | int pthread_once( control , routine )
40 | pthread_once_t * control ;
41 | void ( * routine )() ;
42 | {
43 | if ( * control == PTHREAD_ONCE_INIT ) {
44 | ( * control ) ++ ;
45 | ( * routine )() ;
46 | }
47 | return 0 ;
48 | }
49 |
50 |
51 | /**
52 | * dl_tls_index : argument passé à __tls_get_addr().
53 | */
54 | typedef struct dl_tls_index
55 | {
56 | uint64_t ti_module;
57 | uint64_t ti_offset;
58 | } tls_index;
59 |
60 |
61 | /**
62 | * __tls_get_addr() : retourne l'adresse d'une variable "thread local".
63 | * Cela n'a pas de sens en mode UEFI : un seul thread est possible donc
64 | * la fonction retourne juste l'adresse qui a été ajustée par _relocate
65 | * du module relocate.
66 | */
67 | void *
68 | __tls_get_addr ( ti )
69 | tls_index * ti ;
70 | {
71 | UEFI_dprintf( D_DEBUG | D_INIT , "__tls_get_addr( mod=%ld , off=%p )\n" , ti-> ti_module , (void *) ti-> ti_offset ) ;
72 | /*
73 | __fortify_fail( "__tls_get_addr()" ) ;
74 | */
75 | return (void*) ti-> ti_offset ;
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/time.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en mars 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Gestion du temps.
18 | * En fait la fonction time() n'est pas utilisée ici pour avoir une
19 | * référence à l'heure mais seulment pour initialiser le générateur
20 | * de nombres aléatoires ainsi que par libmy pour sa fonction delay().
21 | * La fonction time() codée ici ne retourne par la bonne valeur (nombre
22 | * de secondes depuis le 1er janvier 1970, 0h GMT) mais celle-ci
23 | * s'incrémente tout de même à chaque seconde sauf peut-être aux moments
24 | * spéciaux de bascule heure d'hiver / heure d'été.
25 | *
26 | */
27 |
28 |
29 | /* en premier */
30 | #include "uefi.h"
31 | #include "debug.h"
32 |
33 | #include
34 |
35 |
36 | /**
37 | * time() : Retourne une valeur bidon qui change à chaque seconde.
38 | */
39 | time_t time( ptr )
40 | time_t * ptr ;
41 | {
42 | EFI_STATUS status ;
43 | EFI_TIME tim ;
44 | EFI_TIME_CAPABILITIES cap ;
45 | time_t val ;
46 | status = UEFI_call( RT-> GetTime , & tim , & cap ) ;
47 | if ( status == EFI_SUCCESS ) val = 0 ;
48 | val = val + tim. Year - 1970 ;
49 | val = val * 12 + tim. Month - 1 ;
50 | val = val * 31 + tim. Day - 1 ;
51 | val = val * 24 + tim. Hour ;
52 | val = val * 60 + tim. Minute + tim. TimeZone ;
53 | val = val * 60 + tim. Second ;
54 | if ( ptr ) * ptr = val ;
55 | return val ;
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/uefi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * Original work is copyleft Bernard Burette.
9 | * Modifications are copyleft Joseph Zeller.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | * Définitions pour notre colle entre UEFI et un programme Linux.
17 | * Définitions pour l'appel des fonctions UEFI.
18 | *
19 | * L'appel aux fonctions UEFI se fait via une macro C définie ici.
20 | * Le nombre d'arguments passé à la macro est calculé automatiquement
21 | * via un peu de magie des macros C pour appeller la fonction efi_callX
22 | * appropriée.
23 | * Celles-ci se trouvent dans le fichier efi_stub.S dans la librairie
24 | * gnuefi.
25 | */
26 |
27 |
28 | /* Pas de double inclusion. */
29 | #ifndef uefi_h_INCLUDED
30 | #define uefi_h_INCLUDED
31 |
32 |
33 | /* Pour obtenir la définition de "struct stat64" depuis sys/stat.h
34 | il faut faire cela en tout premier sinon le fichier sys/types.h
35 | aura déjà été inclus par un autre fichier d'en-tête mais sans
36 | cette définition. */
37 | #define _LARGEFILE64_SOURCE 1
38 | #include
39 |
40 |
41 | /* Pour éviter des inline qui retournent des "double" ce qui n'est pas
42 | * autorisé en mode UEFI où la partie MMS/SSE du processeur n'est pas
43 | * encore initialisée. */
44 | #undef __USE_EXTERN_INLINES
45 | #include
46 |
47 |
48 | /* This file is included from C++ source files */
49 | #if defined( __cplusplus )
50 | extern "C" {
51 | #endif
52 |
53 |
54 | /* GNU EFI includes */
55 | #include
56 | #include
57 |
58 |
59 | /**
60 | * UEFI Image Handle provided on code entry.
61 | * Exporté du module start-$(ARCH).
62 | */
63 | extern EFI_HANDLE UEFI_ImageHandle ;
64 |
65 |
66 | /**
67 | * UEFI System Table provided on code entry.
68 | * Exporté des modules start-$(ARCH) et de la librairie GNU EFI.
69 | */
70 | extern EFI_SYSTEM_TABLE * ST ;
71 |
72 |
73 | /**
74 | * Une erreur qui abandonne l'exécution.
75 | * Affiche un message puis termine l'exécution.
76 | * La fonction est dans initfini.c.
77 | * @param mess Le message.
78 | */
79 | extern void __fortify_fail( const char * msg ) __attribute__((noreturn)) ;
80 |
81 |
82 | /**
83 | * Construit le nom d'un disque d'après son handle UEFI.
84 | * @param handle Le EFI_HANDLE dont on souhaite obtenir une représentation.
85 | * @return Un buffer "static" qui contient cela (ce code n'est pas
86 | multi-thread).
87 | * La fonction est dans io.c.
88 | */
89 | const char * UEFI_disk_name( EFI_HANDLE handle ) ;
90 |
91 |
92 | /**
93 | * Lit un caractère depuis la console.
94 | * @return Le caractère Unicode lu
95 | * ou -1 en cas d'erreur (consulter errno).
96 | * La fonction est dans io.c.
97 | */
98 | long UEFI_console_getchar() ;
99 |
100 |
101 | /**
102 | * Écrit un caractère sur la console.
103 | * @param c Le caractère Unicode à écrire.
104 | * @param e Écrire sur StdErr pluôt que ConOut.
105 | * @return Le caractère Unicode écrit convertit en int
106 | * ou -1 en cas d'erreur (consulter errno).
107 | * La fonction est dans io.c.
108 | */
109 | int UEFI_console_putchar( long c , char e ) ;
110 |
111 |
112 | /**
113 | * La macro UEFI_call() appelle une fonction du firmware UEFI.
114 | * Le premier argument est la fonction, les autres sont ses arguments.
115 | */
116 | #define UEFI_call( fun , ... ) UEFI_call_count( __VA_ARGS__ ) \
117 | ( fun , __VA_ARGS__ )
118 |
119 | #define UEFI_call_count( ... ) UEFI_call_count2( \
120 | UEFI_call_count4( __VA_ARGS__ ) , __VA_ARGS__ )
121 |
122 | #define UEFI_call_count2( quantite , ... ) \
123 | UEFI_call_count3( quantite , __VA_ARGS__ )
124 |
125 | #define UEFI_call_count3( quantite , ... ) UEFI_call##quantite
126 |
127 | #define UEFI_call_count4( ... ) UEFI_call_count5( __VA_ARGS__ , \
128 | 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 , inutile )
129 |
130 | #define UEFI_call_count5( un , deux , trois , quatre , cinq , six , sept , \
131 | huit , neuf , dix , onze , douze , ... ) onze
132 |
133 | #define UEFI_call1( f , a1 ) efi_call1( (void*) ( f ) , \
134 | (UINTN) ( a1 ) )
135 |
136 | #define UEFI_call2( f , a1 , a2 ) efi_call2( (void*) ( f ) , \
137 | (UINTN) ( a1 ) , (UINTN) ( a2 ) )
138 |
139 | #define UEFI_call3( f , a1 , a2 , a3 ) efi_call3( (void*) ( f ) , \
140 | (UINTN) ( a1 ) , (UINTN) ( a2 ) , (UINTN) ( a3 ) )
141 |
142 | #define UEFI_call4( f , a1 , a2 , a3 , a4 ) efi_call4( (void*) ( f ) , \
143 | (UINTN) ( a1 ) , (UINTN) ( a2 ) , (UINTN) ( a3 ) , (UINTN) ( a4 ) )
144 |
145 | #define UEFI_call5( f , a1 , a2 , a3 , a4 , a5 ) efi_call5( (void*) ( f ) , \
146 | (UINTN) ( a1 ) , (UINTN) ( a2 ) , (UINTN) ( a3 ) , (UINTN) ( a4 ) , \
147 | (UINTN) ( a5 ) )
148 |
149 | #define UEFI_call6( f , a1 , a2 , a3 , a4 , a5 , a6 ) efi_call6( (void*) ( f ) , \
150 | (UINTN) ( a1 ) , (UINTN) ( a2 ) , (UINTN) ( a3 ) , (UINTN) ( a4 ) , \
151 | (UINTN) ( a5 ) , (UINTN) ( a6 ) )
152 |
153 | #if defined( __cplusplus )
154 | }
155 | #endif
156 |
157 |
158 | #endif /* uefi_h_INCLUDED */
159 |
160 |
--------------------------------------------------------------------------------
/uuid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of UEFI GPT fdisk.
3 | *
4 | * UEFI GPT fdisk is a port of GPT fdisk to UEFI/BIOS.
5 | * UEFI GPT fdisk est un portage de GPT fdisk vers UEFI/BIOS.
6 | * Ce fichier a été initié par Bernard Burette en janvier 2014.
7 | *
8 | * All this work is copyleft Bernard Burette.
9 | * Gauche d'auteur Bernard Burette.
10 | *
11 | * This program is distributed under the terms of the GNU GPL version 2.
12 | * La diffusion de ce code est faite selon les termes de la GPL GNU version 2.
13 | */
14 |
15 | /**
16 | *
17 | * Fonction de génération de nombres aléatoires et de UUID.
18 | *
19 | */
20 |
21 |
22 | /* en premier */
23 | #include "uefi.h"
24 | #include "debug.h"
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 |
33 | /**
34 | * Racine pour les nombres aléatoires.
35 | */
36 | static uint32_t holdrand = 1 ;
37 |
38 | /**
39 | * Positionne la racine.
40 | */
41 | void srand( seed )
42 | unsigned int seed ;
43 | {
44 | UEFI_dprintf( D_INIT | D_DEBUG , "--> srand(%d)\n" , seed ) ;
45 | /* store this seed */
46 | holdrand = (uint32_t) seed ;
47 | UEFI_dprintf( D_INIT | D_DEBUG , "<-- srand()\n" ) ;
48 | }
49 |
50 | /*
51 | * Génère un nombre aléatoire.
52 | */
53 | int rand()
54 | {
55 | /* return a pseudo-random in range 0-0x7fff */
56 | return ( ( holdrand = holdrand * 214013L + 2531011L ) >> 16 )
57 | & 0x7fff ;
58 | }
59 |
60 | /*
61 | * Construit un UUID.
62 | */
63 | void uuid_generate( out )
64 | uuid_t out ;
65 | {
66 | size_t i ;
67 | /* generates 128 random bits for new UUID */
68 | for ( i = 0 ; i < 16 ; i ++ ) {
69 | int v ;
70 | /* if we didn't knew max rand() value and since the most
71 | random bits are the most significant we would do
72 | v=(int)(256.0f*((float)rand()/(RAND_MAX+1.0f)));
73 | but here it is simpler beacuse RAND_MAX == 0x7fff */
74 | v = rand() >> 7 ;
75 | out[ i ] = (unsigned char) v ;
76 | }
77 | /* set variant 10x and version 4 as required by RFC 4122 */
78 | out[ 8 ] = 0x80 | ( out[ 8 ] & 0x3f ) ;
79 | out[ 6 ] = 0x40 | ( out[ 6 ] & 0xf ) ;
80 | }
81 |
82 |
--------------------------------------------------------------------------------