mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[liba] Add a bridge for incomplete libc
For example, GLIBC doesn't provide strlcpy which we want to use Change-Id: Iebbadfd42ca8e5dc089a8fe0b670fef843a10027
This commit is contained in:
1
Makefile
1
Makefile
@@ -53,6 +53,7 @@ info:
|
||||
@echo "==============================="
|
||||
|
||||
ifeq ($(USE_LIBA),0)
|
||||
include liba/Makefile.bridge
|
||||
else
|
||||
SFLAGS += -ffreestanding -nostdinc -nostdlib
|
||||
include liba/Makefile
|
||||
|
||||
@@ -11,12 +11,7 @@ Graph::Function::Function(const char * text, KDColor color) :
|
||||
}
|
||||
|
||||
void Graph::Function::setContent(const char * c) {
|
||||
#if __GLIBC__
|
||||
// FIXME: This is ugly.
|
||||
strncpy(m_text, c, sizeof(m_text));
|
||||
#else
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
#endif
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
}
|
||||
|
||||
3
liba/Makefile.bridge
Normal file
3
liba/Makefile.bridge
Normal file
@@ -0,0 +1,3 @@
|
||||
SFLAGS += -Iliba/include/bridge
|
||||
|
||||
objs += liba/src/bridge.o
|
||||
16
liba/include/bridge/string.h
Normal file
16
liba/include/bridge/string.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef LIBA_BRIDGE_STRING_H
|
||||
#define LIBA_BRIDGE_STRING_H
|
||||
|
||||
#include_next <string.h>
|
||||
|
||||
#include "../private/macros.h"
|
||||
|
||||
LIBA_BEGIN_DECLS
|
||||
|
||||
#if __GLIBC__
|
||||
size_t strlcpy(char * dst, const char * src, size_t len);
|
||||
#endif
|
||||
|
||||
LIBA_END_DECLS
|
||||
|
||||
#endif
|
||||
5
liba/src/bridge.c
Normal file
5
liba/src/bridge.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <string.h>
|
||||
|
||||
#if __GLIBC__
|
||||
#include "strlcpy.c"
|
||||
#endif
|
||||
Reference in New Issue
Block a user