fix linux-specific compilation errors

This commit is contained in:
2024-10-27 15:36:14 +00:00
parent e77c3908eb
commit a86291ca75
5 changed files with 15 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
#include <blue/core/random.h>
#include <printf.h>
#include <stdio.h>
#define NRAND_NUMBERS 12
#define NRAND_BYTES 128

View File

@@ -1,6 +1,10 @@
#ifndef BLUELIB_MISB_H_
#define BLUELIB_MISB_H_
#ifndef _Nonnull
#define _Nonnull
#endif
#define b_unbox(type, box, member) \
((type *_Nonnull)((box) ? (uintptr_t)(box) - (offsetof(type, member)) : 0))

View File

@@ -125,7 +125,7 @@ static void init_by_array64(
}
/* generates a random number on [0, 2^64-1]-interval */
static unsigned long long genrand64_int64(struct b_random_ctx *context)
static uint64_t genrand64_int64(struct b_random_ctx *context)
{
#if 0
/* This is the original implementation. It is replaced by the alternate implementation, below. */

View File

@@ -1,8 +1,8 @@
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
uint64_t z__c_platform_random_seed()
uint64_t z__b_platform_random_seed()
{
int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1) {
@@ -18,7 +18,7 @@ uint64_t z__c_platform_random_seed()
return v;
}
uint64_t z__c_platform_random_seed_secure()
uint64_t z__b_platform_random_seed_secure()
{
int fd = open("/dev/random", O_RDONLY);
if (fd == -1) {

View File

@@ -1,15 +1,15 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
int z__c_stream_is_tty(FILE *fp)
int z__b_stream_is_tty(FILE *fp)
{
return isatty(fileno(fp));
}
int z__c_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h)
int z__b_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h)
{
if (!isatty(fileno(fp))) {
return -1;
@@ -31,7 +31,7 @@ int z__c_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h)
return 0;
}
int z__c_stream_cursorpos(FILE *in, FILE *out, unsigned int *x, unsigned int *y)
int z__b_stream_cursorpos(FILE *in, FILE *out, unsigned int *x, unsigned int *y)
{
if (!isatty(fileno(in)) || !isatty(fileno(out))) {
return -1;