Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #41 from UteroOS/restructure-for-libcr-#38
Browse files Browse the repository at this point in the history
Restructure for libcr #38
  • Loading branch information
noriyotcp authored Mar 17, 2017
2 parents 06a5a9d + 1b5e932 commit 8e13666
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 10 deletions.
3 changes: 3 additions & 0 deletions REFERENCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This is a great OS **almost** written in Crystal!

https://github.com/TheKernelCorp/NuummiteOS

### Cyanurus
https://github.com/redcap97/cyanurus

-----

### Create Your Own Operating System: Build, deploy, and test your very own operating systems for the Internet of Things and other devices Kindle Edition
Expand Down
35 changes: 35 additions & 0 deletions src/core/lib_cr.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2016-2017 Utero OS Developers. See the COPYRIGHT
# file at the top-level directory of this distribution.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

# This was taken from crystal/src/lib_c.cr

lib LibCR
alias Char = UInt8
alias UChar = Char
alias SChar = Int8
alias Short = Int16
alias UShort = UInt16
alias Int = Int32
alias UInt = UInt32

{% if flag?(:x86_64) || flag?(:aarch64) %}
alias Long = Int64
alias ULong = UInt64
{% elsif flag?(:i686) || flag?(:arm) %}
alias Long = Int32
alias ULong = UInt32
{% end %}

alias LongLong = Int64
alias ULongLong = UInt64
alias Float = Float32
alias Double = Float64

$environ : Char**
end
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.

# from crystal/src/lib_c.cr
# This was take from
# crystal/src/lib_c/x86_64-linux-musl/c/stddef.cr

# Lookup core/lib_cr.cr
require "../../../lib_cr"

lib LibCR
alias ULong = UInt64 # for x86_64
alias SizeT = ULong
alias Char = UInt8
alias Int = Int32
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ require "./stddef"
lib LibCR
fun memchr(x0 : Void*, c : Int, n : SizeT) : Void*
fun memcmp(x0 : Void*, x1 : Void*, x2 : SizeT) : Int
fun memset(dest : Void*, src : Int, len : SizeT) : Void*
fun strchr(x0 : Char*, x1 : Int) : Char*
fun strchrnul(x0 : Char*, x1 : Int) : Char*
fun strcmp(x0 : Char*, x1 : Char*) : Int
# fun strerror(x0 : Int) : Char*
fun strlen(x0 : Char*) : SizeT

# Additional functions
fun memset(dest : Void*, src : Int, len : SizeT) : Void*
fun strchr(x0 : Char*, x1 : Int) : Char*
fun strchrnul(x0 : Char*, x1 : Int) : Char*
fun strncmp(x0 : Char*, x1 : Char*, n : SizeT) : Int
fun strstr(x0 : Char*, x1 : Char*) : Char*
end
5 changes: 2 additions & 3 deletions src/core/prelude.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# except according to those terms.

# Order-dependent list
require "../lib_cr/string"
require "../lib_cr/ctype"
require "../lib_cr/bits/**"
require "./lib_cr"
require "./lib_cr/**"
require "./string"

# Alpha-sorted list
Expand Down

0 comments on commit 8e13666

Please sign in to comment.