Files
player/Project/Src/lib/libc.h

62 lines
1.1 KiB
C
Raw Normal View History

2025-06-27 00:32:57 +08:00
#ifndef libc_h__
#define libc_h__
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
2025-06-27 00:32:57 +08:00
typedef struct
{
const char *name;
int (*open)(void);
int (*close)(void);
int (*putc)(int);
int (*getc)(void);
int (*write)(const void *,int);
int (*read)(void *,int);
}libc_device_file;
2025-07-05 19:47:28 +08:00
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
2025-06-27 00:32:57 +08:00
#define extern_device(name_,putc_,getc_,write_,read_)\
2025-06-29 11:20:46 +08:00
const char __libc_##name_[] __attribute__((section(".name"))) = #name_;\
__attribute__((used,section(".libc_dev"))) const libc_device_file __libc_dev_##name_ =\
2025-06-27 00:32:57 +08:00
{\
.name=__libc_##name_,\
.putc=putc_,\
.getc=getc_,\
.write=write_,\
.read=read_,\
};
2025-07-05 19:47:28 +08:00
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD><EFBFBD>򿪹رպ<D8B1><D5BA><EFBFBD>
2025-06-27 00:32:57 +08:00
#define extern_device2(name_,open_,close_,putc_,getc_,write_,read_)\
2025-06-29 11:20:46 +08:00
const char __libc_##name_[] __attribute__((section(".name"))) = #name_;\
__attribute__((used,section(".libc_dev"))) const libc_device_file __libc_dev_##name_ =\
2025-06-27 00:32:57 +08:00
{\
.name=__libc_##name_,\
.open=open_,\
.close=close_,\
.putc=putc_,\
.getc=getc_,\
.write=write_,\
.read=read_,\
};
#define dev(name_) __libc_dev_##name_
2025-06-29 11:20:46 +08:00
const libc_device_file *libc_find_dev(const char *name);
2025-06-27 00:32:57 +08:00
#endif