mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibC: Add some integer functionality needed for NASM.
This commit is contained in:
parent
caff611ca3
commit
ddb13ae6d8
4 changed files with 29 additions and 0 deletions
|
@ -1 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define PRId8 "d"
|
||||||
|
#define PRId16 "d"
|
||||||
|
#define PRId32 "d"
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef unsigned long long int uint64_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
|
|
||||||
|
typedef signed long long int int64_t;
|
||||||
typedef signed int int32_t;
|
typedef signed int int32_t;
|
||||||
typedef signed short int16_t;
|
typedef signed short int16_t;
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
|
|
|
@ -267,4 +267,20 @@ int system(const char* command)
|
||||||
return execl("/bin/sh", "sh", "-c", command, nullptr);
|
return execl("/bin/sh", "sh", "-c", command, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div_t div(int numerator, int denominator)
|
||||||
|
{
|
||||||
|
div_t result;
|
||||||
|
result.quot = numerator / denominator;
|
||||||
|
result.rem = numerator % denominator;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ldiv_t ldiv(long numerator, long denominator)
|
||||||
|
{
|
||||||
|
ldiv_t result;
|
||||||
|
result.quot = numerator / denominator;
|
||||||
|
result.rem = numerator % denominator;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,10 @@ void srand(unsigned seed);
|
||||||
long int random();
|
long int random();
|
||||||
void srandom(unsigned seed);
|
void srandom(unsigned seed);
|
||||||
|
|
||||||
|
typedef struct { int quot; int rem; } div_t;
|
||||||
|
div_t div(int, int);
|
||||||
|
typedef struct { long quot; long rem; } ldiv_t;
|
||||||
|
ldiv_t ldiv(long, long);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue