Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/store/store_mem.c # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / store / store_mem.c` 56 lines ยท 1640 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* store_mem.c -- memcpy/memmove/memset/memcmp for the freestanding build 18 * (make freestanding) only. Hosted builds use libc. Compiled with 19 * -fno-builtin -fno-tree-loop-distribute-patterns so the loops are not 20 * turned back into calls to themselves. */ 21 #include 22 23 void *memcpy(void *restrict d, const void *restrict s, size_t n) 24 { 25 unsigned char *a = d; 26 const unsigned char *b = s; 27 while (n--) *a++ = *b++; 28 return d; 29 } 30 31 void *memmove(void *d, const void *s, size_t n) 32 { 33 unsigned char *a = d; 34 const unsigned char *b = s; 35 if (a < b) { 36 while (n--) *a++ = *b++; 37 } else { 38 while (n--) a[n] = b[n]; 39 } 40 return d; 41 } 42 43 void *memset(void *d, int c, size_t n) 44 { 45 unsigned char *a = d; 46 while (n--) *a++ = (unsigned char)c; 47 return d; 48 } 49 50 int memcmp(const void *x, const void *y, size_t n) 51 { 52 const unsigned char *a = x, *b = y; 53 for (; n; n--, a++, b++) 54 if (*a != *b) return *a < *b ? -1 : 1; 55 return 0; 56 }