PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
elf.h
Go to the documentation of this file.
1#ifndef _LIBSTD_COMMON_ELF_H
2#define _LIBSTD_COMMON_ELF_H 1
3
4#include <errno.h>
5#include <stddef.h>
6#include <sys/elf.h>
7
8// Makes sure both the kernel and bootloader can use the elf functions
9#ifdef _BOOT_
10#include <efi.h>
11#include <efilib.h>
12
13#define elf_strcmp(Str1, Str2) strcmpa((Str1), (Str2))
14#define elf_memcpy(Dest, Src, Size) CopyMem((Dest), (Src), (Size))
15#define elf_memset(Dest, Value, Size) SetMem((Dest), (Size), (Value))
16
17static void* elf_memchr(const void* ptr, int value, size_t num)
18{
19 const unsigned char* p = (const unsigned char*)ptr;
20 for (size_t i = 0; i < num; i++)
21 {
22 if (p[i] == (unsigned char)value)
23 {
24 return (void*)&p[i];
25 }
26 }
27 return NULL;
28}
29
30#else
31
32#include <string.h>
33
34#define elf_strcmp strcmp
35#define elf_memcpy memcpy
36#define elf_memset memset
37#define elf_memchr memchr
38
39#endif
40
41#ifdef _KERNEL_
42#include <kernel/log/log.h>
43#endif
44
45#endif // _LIBSTD_COMMON_ELF_H
#define NULL
Pointer error value.
Definition NULL.h:23
#define elf_memchr
Definition elf.h:37