diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-03 15:27:44 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-03 15:27:44 -0500 |
| commit | 792743dff3b4af6df030a53e447b28a8a3e8b072 (patch) | |
| tree | fe72f941171680790c4359979a4078008a3cecea | |
| parent | f656c9eb26154c206915f5f643d88f805315d3b0 (diff) | |
Add Int64:unsigned_left_shift() and :unsigned_right_shift()
| -rw-r--r-- | environment.c | 8 | ||||
| -rw-r--r-- | stdlib/integers.h | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/environment.c b/environment.c index ec4043a2..2cd94f7e 100644 --- a/environment.c +++ b/environment.c @@ -138,6 +138,8 @@ env_t *new_compilation_unit(CORD libname) {"modulo1", "Int64$modulo1", "func(x,y:Int64 -> Int64)"}, {"octal", "Int64$octal", "func(i:Int64, digits=0, prefix=yes -> Text)"}, {"to", "Int64$to", "func(from:Int64,to:Int64 -> Range)"}, + {"unsigned_left_shift", "Int64$unsigned_left_shift", "func(x:Int64,y:Int64 -> Int64)"}, + {"unsigned_right_shift", "Int64$unsigned_right_shift", "func(x:Int64,y:Int64 -> Int64)"}, {"wrapping_minus", "Int64$wrapping_minus", "func(x:Int64,y:Int64 -> Int64)"}, {"wrapping_plus", "Int64$wrapping_plus", "func(x:Int64,y:Int64 -> Int64)"}, // Must be defined after min/max: @@ -157,6 +159,8 @@ env_t *new_compilation_unit(CORD libname) {"modulo1", "Int32$modulo1", "func(x,y:Int32 -> Int32)"}, {"octal", "Int32$octal", "func(i:Int32, digits=0, prefix=yes -> Text)"}, {"to", "Int32$to", "func(from:Int32,to:Int32 -> Range)"}, + {"unsigned_left_shift", "Int32$unsigned_left_shift", "func(x:Int32,y:Int32 -> Int32)"}, + {"unsigned_right_shift", "Int32$unsigned_right_shift", "func(x:Int32,y:Int32 -> Int32)"}, {"wrapping_minus", "Int32$wrapping_minus", "func(x:Int32,y:Int32 -> Int32)"}, {"wrapping_plus", "Int32$wrapping_plus", "func(x:Int32,y:Int32 -> Int32)"}, // Must be defined after min/max: @@ -176,6 +180,8 @@ env_t *new_compilation_unit(CORD libname) {"modulo1", "Int16$modulo1", "func(x,y:Int16 -> Int16)"}, {"octal", "Int16$octal", "func(i:Int16, digits=0, prefix=yes -> Text)"}, {"to", "Int16$to", "func(from:Int16,to:Int16 -> Range)"}, + {"unsigned_left_shift", "Int16$unsigned_left_shift", "func(x:Int16,y:Int16 -> Int16)"}, + {"unsigned_right_shift", "Int16$unsigned_right_shift", "func(x:Int16,y:Int16 -> Int16)"}, {"wrapping_minus", "Int16$wrapping_minus", "func(x:Int16,y:Int16 -> Int16)"}, {"wrapping_plus", "Int16$wrapping_plus", "func(x:Int16,y:Int16 -> Int16)"}, // Must be defined after min/max: @@ -195,6 +201,8 @@ env_t *new_compilation_unit(CORD libname) {"modulo1", "Int8$modulo1", "func(x,y:Int8 -> Int8)"}, {"octal", "Int8$octal", "func(i:Int8, digits=0, prefix=yes -> Text)"}, {"to", "Int8$to", "func(from:Int8,to:Int8 -> Range)"}, + {"unsigned_left_shift", "Int8$unsigned_left_shift", "func(x:Int8,y:Int8 -> Int8)"}, + {"unsigned_right_shift", "Int8$unsigned_right_shift", "func(x:Int8,y:Int8 -> Int8)"}, {"wrapping_minus", "Int8$wrapping_minus", "func(x:Int8,y:Int8 -> Int8)"}, {"wrapping_plus", "Int8$wrapping_plus", "func(x:Int8,y:Int8 -> Int8)"}, // Must be defined after min/max: diff --git a/stdlib/integers.h b/stdlib/integers.h index 2293e065..ea286202 100644 --- a/stdlib/integers.h +++ b/stdlib/integers.h @@ -66,6 +66,12 @@ } \ MACROLIKE PUREFUNC c_type type_name ## $wrapping_minus(c_type x, c_type y) { \ return (c_type)((u##c_type)x + (u##c_type)y); \ + } \ + MACROLIKE PUREFUNC c_type type_name ## $unsigned_left_shift(c_type x, c_type y) { \ + return (c_type)((u##c_type)x << y); \ + } \ + MACROLIKE PUREFUNC c_type type_name ## $unsigned_right_shift(c_type x, c_type y) { \ + return (c_type)((u##c_type)x >> y); \ } DEFINE_INT_TYPE(int64_t, Int64, __attribute__(())) |
