Stuff
This commit is contained in:
parent
6f4a616eb6
commit
b6ea3c20fe
|
@ -72,7 +72,7 @@ common: $(COMMDEPS) $(COMMDIR)/lib/string.c $(COMMDIR)/lib/status.c
|
||||||
|
|
||||||
CCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES)
|
CCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES)
|
||||||
|
|
||||||
common-test:
|
test-common:
|
||||||
$(CCC) -c $(COMMDIR)/lib/string.c -o $(COBJDIR)/lib/string.o
|
$(CCC) -c $(COMMDIR)/lib/string.c -o $(COBJDIR)/lib/string.o
|
||||||
$(CCC) -c $(COMMDIR)/lib/status.c -o $(COBJDIR)/lib/status.o
|
$(CCC) -c $(COMMDIR)/lib/status.c -o $(COBJDIR)/lib/status.o
|
||||||
$(CCC) -c $(COMMDIR)/lib/memory.c -o $(COBJDIR)/lib/memory.o
|
$(CCC) -c $(COMMDIR)/lib/memory.c -o $(COBJDIR)/lib/memory.o
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
// GNU GPL OS/K //
|
GNU GPL OS/K
|
||||||
// //
|
|
||||||
// Authors: spectral` //
|
Authors: spectral`
|
||||||
// NeoX //
|
NeoX
|
||||||
// //
|
|
||||||
// Desc: Folder description - "boot" //
|
Desc: Folder description - "boot"
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
This folder contains the source for OS/K's bootloader.
|
This folder contains the source for OS/K's bootloader.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
// GNU GPL OS/K //
|
GNU GPL OS/K
|
||||||
// //
|
|
||||||
// Authors: spectral` //
|
Authors: spectral`
|
||||||
// NeoX //
|
NeoX
|
||||||
// //
|
|
||||||
// Desc: Folder description - "kaleid/common" //
|
Desc: Folder description - "kaleid/common"
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
This is the folder containing the sources for Kaleid's C runtime library, linked both to the kernel
|
This is the folder containing the sources for Kaleid's C runtime library, linked both to the kernel
|
||||||
and to the system processes that run outiside the kernel. It can also be compiled for Linux as
|
and to the system processes that run outiside the kernel. It can also be compiled for Linux as
|
||||||
|
|
|
@ -38,18 +38,31 @@ char *strcpy(char *dest, const char *src)
|
||||||
//
|
//
|
||||||
char *strncpy(char *dest, const char *src, size_t n)
|
char *strncpy(char *dest, const char *src, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t it;
|
||||||
|
|
||||||
for (i = 0; i < n && src[i]; i++) {
|
for (it = 0; it < n && src[it]; i++) {
|
||||||
dest[i] = src[i];
|
dest[it] = src[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < n) dest[i++] = 0;
|
while (it < n) dest[it++] = 0;
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reverses a string
|
// Reverses the string src, putting the result into dest
|
||||||
|
//
|
||||||
|
char *strrev(char *dest, const char *src)
|
||||||
|
{
|
||||||
|
size_t m = 0, n = strlen(src);
|
||||||
|
|
||||||
|
dest[n--] = '\0';
|
||||||
|
|
||||||
|
while (n) dest[m++] = src[n--];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reverses a string, modifying it
|
||||||
|
// Returns a point to said string
|
||||||
//
|
//
|
||||||
char *reverse(char *str)
|
char *reverse(char *str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
// Authors: spectral` //
|
// Authors: spectral` //
|
||||||
// NeoX //
|
// NeoX //
|
||||||
// //
|
// //
|
||||||
// Desc: mem*() functions - sub-optimal version //
|
// Desc: mem*() functions //
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// XXX to be improved before being brought back
|
||||||
|
// to be tested with more alignment sizes
|
||||||
|
|
||||||
#include "common/memory.h"
|
#include "common/memory.h"
|
||||||
|
|
||||||
// to be moved
|
// to be moved
|
||||||
|
@ -34,9 +37,9 @@ static inline void *memsetq(void *ptr, ullong uval, size_t qwords)
|
||||||
// This is most certainely overkill, but I enjoyed doing this
|
// This is most certainely overkill, but I enjoyed doing this
|
||||||
// Alignment stuff barely matters on modern processors
|
// Alignment stuff barely matters on modern processors
|
||||||
//
|
//
|
||||||
void *memset(void *ptr, register int val, register size_t bytes)
|
void *memset(void *ptr, int val, size_t bytes)
|
||||||
{
|
{
|
||||||
register uchar *uptr = (uchar *)ptr;
|
uchar *uptr = (uchar *)ptr;
|
||||||
const size_t qwords = bytes/QWORD_SIZE;
|
const size_t qwords = bytes/QWORD_SIZE;
|
||||||
|
|
||||||
// get rid of everything after the first byte
|
// get rid of everything after the first byte
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
// GNU GPL OS/K //
|
GNU GPL OS/K
|
||||||
// //
|
|
||||||
// Authors: spectral` //
|
Authors: spectral`
|
||||||
// NeoX //
|
NeoX
|
||||||
// //
|
|
||||||
// Desc: Folder description - "kaleid/kernel" //
|
Desc: Folder description - "kaleid/kernel"
|
||||||
//----------------------------------------------------------------------------//
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
This folder contains the source of Kaleid's kernel component.
|
This folder contains the source of Kaleid's kernel component.
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
// Desc: Test file for common/ //
|
// Desc: Test file for common/ //
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#define KEEP_KALCOMM_TYPES_MINIMAL
|
#define KEEP_KALCOMM_TYPES_MINIMAL
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
@ -37,6 +36,21 @@ int main(int argc, char *argv[])
|
||||||
//printf("%p\n",xxx);
|
//printf("%p\n",xxx);
|
||||||
//memset(xxx, 'x', sizex);
|
//memset(xxx, 'x', sizex);
|
||||||
|
|
||||||
|
const char *str = "ceci est un string de test\n";
|
||||||
|
char *str2 = malloc((strlen(str) + 3) * sizeof(char));
|
||||||
|
|
||||||
|
strcpy(str2, str);
|
||||||
|
|
||||||
|
size_t s = strlen(str2);
|
||||||
|
|
||||||
|
printf(reverse(reverse(str2)));
|
||||||
|
|
||||||
|
str2[s] = '\n';
|
||||||
|
str2[s+1] = '\0';
|
||||||
|
printf(reverse(reverse(str2)));
|
||||||
|
|
||||||
|
free(str2);
|
||||||
|
|
||||||
/*size_t it;
|
/*size_t it;
|
||||||
for (it = 0; it < sizex; it++) {
|
for (it = 0; it < sizex; it++) {
|
||||||
char c = *(xxx + it);
|
char c = *(xxx + it);
|
||||||
|
|
Loading…
Reference in New Issue