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)
|
||||
|
||||
common-test:
|
||||
test-common:
|
||||
$(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/memory.c -o $(COBJDIR)/lib/memory.o
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Authors: spectral` //
|
||||
// NeoX //
|
||||
// //
|
||||
// Desc: Folder description - "boot" //
|
||||
//----------------------------------------------------------------------------//
|
||||
---------------------------------------------------------------------
|
||||
GNU GPL OS/K
|
||||
|
||||
Authors: spectral`
|
||||
NeoX
|
||||
|
||||
Desc: Folder description - "boot"
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
||||
This folder contains the source for OS/K's bootloader.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Authors: spectral` //
|
||||
// NeoX //
|
||||
// //
|
||||
// Desc: Folder description - "kaleid/common" //
|
||||
//----------------------------------------------------------------------------//
|
||||
---------------------------------------------------------------------
|
||||
GNU GPL OS/K
|
||||
|
||||
Authors: spectral`
|
||||
NeoX
|
||||
|
||||
Desc: Folder description - "kaleid/common"
|
||||
---------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
|
|
@ -38,18 +38,31 @@ char *strcpy(char *dest, const char *src)
|
|||
//
|
||||
char *strncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
size_t it;
|
||||
|
||||
for (i = 0; i < n && src[i]; i++) {
|
||||
dest[i] = src[i];
|
||||
for (it = 0; it < n && src[it]; i++) {
|
||||
dest[it] = src[i];
|
||||
}
|
||||
|
||||
while (i < n) dest[i++] = 0;
|
||||
while (it < n) dest[it++] = 0;
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
// Authors: spectral` //
|
||||
// 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"
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
// get rid of everything after the first byte
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Authors: spectral` //
|
||||
// NeoX //
|
||||
// //
|
||||
// Desc: Folder description - "kaleid/kernel" //
|
||||
//----------------------------------------------------------------------------//
|
||||
---------------------------------------------------------------------
|
||||
GNU GPL OS/K
|
||||
|
||||
Authors: spectral`
|
||||
NeoX
|
||||
|
||||
Desc: Folder description - "kaleid/kernel"
|
||||
---------------------------------------------------------------------
|
||||
|
||||
This folder contains the source of Kaleid's kernel component.
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
// Desc: Test file for common/ //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#define KEEP_KALCOMM_TYPES_MINIMAL
|
||||
|
||||
#include "common/common.h"
|
||||
|
@ -36,6 +35,21 @@ int main(int argc, char *argv[])
|
|||
//void *xxx = malloc(sizex);
|
||||
//printf("%p\n",xxx);
|
||||
//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;
|
||||
for (it = 0; it < sizex; it++) {
|
||||
|
|
Loading…
Reference in New Issue