Commit 89eac61e authored by Kevin Bracey's avatar Kevin Bracey
Browse files

* Added two new library chunks, 4 and 5, which contain extensions to the...

* Added two new library chunks, 4 and 5, which contain extensions to the kernel and C library respectively. These have no static data associated with them, just being extensions of the stub tables. The reason for this is to minimise wasted space in programs that don't use the C99 facilities; o.stubs is now a library split into 3 pieces - basic kernel and CLib, extra kernel and extra

  CLib; only the bits a program needs get included.

* Previous extensions to the C library stubs revoked - they now stop at _swix;
  all the new C99 functions now live in chunk 4. Anyone using those new
  functions should relink with new stubs and ensure this C library version.

* printf/scanf now support 64-bit types through "ll" and "j" length modifiers.

* Run-time support for VLAs (__rt_allocauto and __rt_freeauto) added. No
  attempt is currently made to clear up on longjmp or to cope with someone
  changing the kernel allocator while a VLA is active. These would be a
  future enhancement.

* Added complete 64-bit run-time support (48 functions) to kernel library;
  these functions are compatible with the ones used by the ARM ADS. Many of
  the simpler functions will not normally be used by the compiler, as it
  will generate inline code. There is scope for improvement by switching
  in MULL and CLZ-using forms of multiply and divide when possible.

* llabs and lldiv added to C library.

* Header files corrected in a few areas, and changed to match the C compiler.
  <stdint.h> and <stdbool.h> now require the compiler to be in C99 mode
  (as detected using __STDC_VERSION__).


Version 5.41. Tagged as 'RISC_OSLib-5_41'
parent 280c51dc
......@@ -214,61 +214,5 @@
Entry _swi, imported, , unveneered
Entry _swix, imported, , unveneered
Entry __fpclassifyf, , , unveneered
Entry __fpclassifyd, , , unveneered
Entry __signbitf, , , unveneered
Entry __signbitd, , , unveneered
Entry copysign, , , unveneered
Entry copysignf, , , unveneered
Entry nan, imported, , unveneered
Entry nanf, imported, , unveneered
Entry nextafter, , , unveneered
Entry nextafterf, , , unveneered
Entry fdim, imported, , unveneered
Entry fdimf, imported, , unveneered
Entry fmax, , , unveneered
Entry fmaxf, , , unveneered
Entry fmin, , , unveneered
Entry fminf, , , unveneered
Entry fabsf, imported, , unveneered
Entry hypot, , , unveneered
Entry hypotf, , , unveneered
Entry feclearexcept, imported, , unveneered
Entry fegetexceptflag, imported, , unveneered
Entry feraiseexcept, imported, , unveneered
Entry fesetexceptflag, imported, , unveneered
Entry fetestexcept, imported, , unveneered
Entry fegetround, imported, , unveneered
Entry fesetround, imported, , unveneered
Entry fegetenv, imported, , unveneered
Entry feholdexcept, imported, , unveneered
Entry fesetenv, imported, , unveneered
Entry feupdateenv, imported, , unveneered
Entry _snprintf, imported, , unveneered
Entry snprintf, imported, , unveneered
Entry vsnprintf, imported, , unveneered
Entry vfscanf, imported, , unveneered
Entry vscanf, imported, , unveneered
Entry vsscanf, imported, , unveneered
Entry ceilf, imported, , unveneered
Entry floorf, imported, , unveneered
Entry nearbyint, , , unveneered
Entry nearbyintf, , , unveneered
Entry rint, imported, , unveneered
Entry rintf, imported, , unveneered
Entry lrint, imported, , unveneered
Entry lrintf, imported, , unveneered
Entry round, , , unveneered
Entry roundf, , , unveneered
Entry lround, , , unveneered
Entry lroundf, , , unveneered
Entry trunc, imported, , unveneered
Entry truncf, imported, , unveneered
Entry remainder, , , unveneered
Entry remainderf, , , unveneered
; __va_illegal_arg 0
END
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;-*- Mode: Assembler -*-
;
; Copyright (C) Acorn Computers Ltd., 1989.
;
; Add new entries ONLY AT THE END of the list
;
Entry __fpclassifyf, , , unveneered
Entry __fpclassifyd, , , unveneered
Entry __signbitf, , , unveneered
Entry __signbitd, , , unveneered
Entry copysign, , , unveneered
Entry copysignf, , , unveneered
Entry nan, imported, , unveneered
Entry nanf, imported, , unveneered
Entry nextafter, , , unveneered
Entry nextafterf, , , unveneered
Entry fdim, imported, , unveneered
Entry fdimf, imported, , unveneered
Entry fmax, , , unveneered
Entry fmaxf, , , unveneered
Entry fmin, , , unveneered
Entry fminf, , , unveneered
Entry fabsf, imported, , unveneered
Entry hypot, , , unveneered
Entry hypotf, , , unveneered
Entry feclearexcept, imported, , unveneered
Entry fegetexceptflag, imported, , unveneered
Entry feraiseexcept, imported, , unveneered
Entry fesetexceptflag, imported, , unveneered
Entry fetestexcept, imported, , unveneered
Entry fegetround, imported, , unveneered
Entry fesetround, imported, , unveneered
Entry fegetenv, imported, , unveneered
Entry feholdexcept, imported, , unveneered
Entry fesetenv, imported, , unveneered
Entry feupdateenv, imported, , unveneered
Entry _snprintf, imported, , unveneered
Entry snprintf, imported, , unveneered
Entry vsnprintf, imported, , unveneered
Entry vfscanf, imported, , unveneered
Entry vscanf, imported, , unveneered
Entry vsscanf, imported, , unveneered
Entry ceilf, imported, , unveneered
Entry floorf, imported, , unveneered
Entry nearbyint, , , unveneered
Entry nearbyintf, , , unveneered
Entry rint, imported, , unveneered
Entry rintf, imported, , unveneered
Entry lrint, imported, , unveneered
Entry lrintf, imported, , unveneered
Entry round, , , unveneered
Entry roundf, , , unveneered
Entry lround, , , unveneered
Entry lroundf, , , unveneered
Entry trunc, imported, , unveneered
Entry truncf, imported, , unveneered
Entry remainder, , , unveneered
Entry remainderf, , , unveneered
Entry llabs, , , unveneered
Entry lldiv, , , unveneered
END
......@@ -51,6 +51,12 @@ dataStart
& dataStart
& |CLib_data_end|
& 5
& entries2Start
& entries2End
& 0
& 0
AREA |RTSK$$Data|, READONLY
IMPORT |C$$code$$Base|
......@@ -79,6 +85,10 @@ entriesStart
GET clib.s.cl_entries
entriesEnd
entries2Start
GET clib.s.cl_entry2
entries2End
EXPORT |__main|
; The compiler produces references to this, so it must be defined,
; but it had better not be branched to.
......
......@@ -92,7 +92,9 @@ SharedLibrary SETL {TRUE}
; r6 = requested stack size (in K) << 16
; r6 bit 0 indicates 32-bit mode
ADR r0, |_lib_init_table|
IMPORT |Stub$$Init$$Base|
LDR r0, =|Stub$$Init$$Base|
; ADR r0, |_lib_init_table|
LDR r6, =|__root_stack_size|
CMP r6, #0
MOVEQ r6, #RootStackSize
......@@ -212,7 +214,8 @@ LookupError
LDR r2, [r12, #blocksize]
ADD r2, r2, r1 ; Pointer to high end of block
LDR r3, =|Image$$ZI$$Base|
ADR r0, |_lib_init_table|
LDR r0, =|Stub$$Init$$Base|
; ADR r0, |_lib_init_table|
LDR r6, =|__root_stack_size|
CMP r6, #0
MOVEQ r6, #RootStackSize :SHL: 6
......@@ -324,6 +327,19 @@ LookupError
]
]
|_k_init_block|
& |Image$$RO$$Base|
& |RTSK$$Data$$Base|
& |RTSK$$Data$$Limit|
LTORG
GET clib.s.cl_init
LTORG
AREA |Stub$$Init|, CODE, READONLY
|_lib_init_table|
& 1
& |_k_entries_start|
......@@ -348,18 +364,9 @@ LookupError
]
]
& -1
|_k_init_block|
& |Image$$RO$$Base|
& |RTSK$$Data$$Base|
& |RTSK$$Data$$Limit|
AREA |Stub$$InitEnd|, CODE, READONLY
LTORG
GET clib.s.cl_init
LTORG
& -1
AREA |Stub$$Entries|, CODE, READONLY
......
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*- Mode: Assembler -*-
;* Lastedit: 08 Mar 90 15:18:04 by Harry Meekings *
;* Shared C library: stub for clients to link with
; 2-Mar-89: IDJ: taken for RISC_OSLib purposes
;
; Copyright (C) Acorn Computers Ltd., 1988.
;
GBLL Brazil_Compatible
GBLL ModeMayBeNonUser
GBLL SharedLibrary
Brazil_Compatible SETL {FALSE}
ModeMayBeNonUser SETL {TRUE}
SharedLibrary SETL {TRUE}
GET s.h_Regs
GET s.h_Brazil
GET s.h_stubs
GET s.h_stack
GET s.h_workspc
AREA |Stub$$Init|, CODE, READONLY
& 5
& |_clib_entries2_start|
& |_clib_entries2_end|
& 0
& 0
AREA |Stub$$Entries|, CODE, READONLY
; Don't GET the stub entries if in ROM
GBLS GetRoundObjAsm
|_clib_entries2_start|
[ Code_Destination = "RAM"
GetRoundObjAsm SETS " GET clib.s.cl_entry2"
|
GetRoundObjAsm SETS ""
]
$GetRoundObjAsm
|_clib_entries2_end|
[ Code_Destination = "RAM" :LAND: APCS_Type <> "APCS-R"
% |_clib_entries2_end| - |_clib_entries2_start|
]
END
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GBLS Calling_Standard
Calling_Standard SETS "APCS_U"
GBLS Code_Destination
Code_Destination SETS "RAM"
LNK clib.s.cl_stub2
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GBLS Calling_Standard
Calling_Standard SETS "APCS_U"
GBLS Code_Destination
Code_Destination SETS "ROM"
GBLL Module_Only
LNK clib.s.cl_stub2
......@@ -60,11 +60,11 @@ typedef struct BlockStruct {
#define SIZEMASK 0x07ffffff /* all except top five bits, when applied */
/* to block.size yields no of address units */
/* of user space in this block. */
#define PUREDATABIT (1<<31) /* indicates the block contains no pointers */
#define NOTGCABLEBIT (1<<30) /* the block is not to be garbage collected */
#define USEDBIT (1<<29) /* if set, indicates that the block is not free */
#define FREEBIT (1<<28) /* if set, indicates that the block is free */
#define HEAPHOLEBIT (1<<27) /* block used for marking start of heap hole */
#define PUREDATABIT (1u<<31) /* indicates the block contains no pointers */
#define NOTGCABLEBIT (1u<<30) /* the block is not to be garbage collected */
#define USEDBIT (1u<<29) /* if set, indicates that the block is not free */
#define FREEBIT (1u<<28) /* if set, indicates that the block is free */
#define HEAPHOLEBIT (1u<<27) /* block used for marking start of heap hole */
#define GUARDCONSTANT 0x3E694C3C /* not a legal word pointer */
#define GCABLE 0
#define GCDATA PUREDATABIT
......
......@@ -55,6 +55,8 @@
EXPORT |_kernel_register_allocs|
EXPORT |_kernel_register_slotextend|
EXPORT |_kernel_alloc|
EXPORT |__rt_allocauto|
EXPORT |__rt_freeauto|
EXPORT |_kernel_current_stack_chunk|
EXPORT |_kernel_stkovf_split_0frame|
......@@ -2566,6 +2568,29 @@ alloc_return_block
; if I do, it complicates malloc and alloc above.
Return ,LinkNotStacked
; In future these could be sophisticated allocators that associate
; allocated blocks with stack chunks, allowing longjmp() et al to
; clear them up. But for now, this suffices for C99's VLAs.
|__rt_allocauto|
FunctionEntry
LoadStaticBase ip, a2
MOV lr, pc
LDR pc, [ip, #O_allocProc]
TEQ a1, #0
Return ,,NE
LoadStaticBase ip, a1
LDR lr, [sp], #4
ADD ip, ip, #O_registerDump
STMIA ip, {a1 - r14}
ADR r0, E_StackOverflow
BL |_kernel_copyerror|
SWI GenerateError
|__rt_freeauto|
LoadStaticBase ip, a2
LDR pc, [ip, #O_freeProc]
;*-------------------------------------------------------------------*
;* Stack chunk handling *
;*-------------------------------------------------------------------*
......@@ -3059,6 +3084,8 @@ s_sh0 RSBS ip, a1, a2
RSBMI a2, a2, #0
Return ,LinkNotStacked
EXPORT __rt_div0
__rt_div0
dividebyzero
; Dump all registers, then enter the abort code.
; We need to discover whether we were doing a divide (in which case,
......
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;-*- Mode: Assembler -*-
; Last modified 20 May 02 16:30:31 by KJB
;
; Copyright (C) Acorn Computers Ltd., 2002.
;
; Add new entries ONLY AT THE END of the list
Entry __rt_allocauto, , , unveneered
Entry __rt_freeauto, , , unveneered
Entry _ll_from_u, imported, , unveneered
Entry _ll_from_l, imported, , unveneered
Entry _ll_to_l, imported, , unveneered
Entry _ll_add, imported, , unveneered
Entry _ll_addlu, imported, , unveneered
Entry _ll_addls, imported, , unveneered
Entry _ll_adduu, imported, , unveneered
Entry _ll_addss, imported, , unveneered
Entry _ll_sub, imported, , unveneered
Entry _ll_sublu, imported, , unveneered
Entry _ll_subls, imported, , unveneered
Entry _ll_subuu, imported, , unveneered
Entry _ll_subss, imported, , unveneered
Entry _ll_rsb, imported, , unveneered
Entry _ll_rsblu, imported, , unveneered
Entry _ll_rsbls, imported, , unveneered
Entry _ll_rsbuu, imported, , unveneered
Entry _ll_rsbss, imported, , unveneered
Entry _ll_mul, imported, , unveneered
Entry _ll_mullu, imported, , unveneered
Entry _ll_mulls, imported, , unveneered
Entry _ll_muluu, imported, , unveneered
Entry _ll_mulss, imported, , unveneered
Entry _ll_udiv, imported, , unveneered
Entry _ll_urdv, imported, , unveneered
Entry _ll_udiv10, imported, , unveneered
Entry _ll_sdiv, imported, , unveneered
Entry _ll_srdv, imported, , unveneered
Entry _ll_sdiv10, imported, , unveneered
Entry _ll_not, imported, , unveneered
Entry _ll_neg, imported, , unveneered
Entry _ll_and, imported, , unveneered
Entry _ll_or, imported, , unveneered
Entry _ll_eor, imported, , unveneered
Entry _ll_shift_l, imported, , unveneered
Entry _ll_ushift_r, imported, , unveneered
Entry _ll_sshift_r, imported, , unveneered
Entry _ll_cmpu, imported, , unveneered
Entry _ll_cmpge, imported, , unveneered
Entry _ll_cmple, imported, , unveneered
Entry _ll_uto_d, imported, , unveneered
Entry _ll_sto_d, imported, , unveneered
Entry _ll_uto_f, imported, , unveneered
Entry _ll_sto_f, imported, , unveneered
Entry _ll_ufrom_d, imported, , unveneered
Entry _ll_sfrom_d, imported, , unveneered
Entry _ll_ufrom_f, imported, , unveneered
Entry _ll_sfrom_f, imported, , unveneered
END
......@@ -51,6 +51,12 @@ dataEnd
& dataStart
& dataEnd
& 4
& entries2Start
& entries2End
& 0
& 0
AREA |RTSK$$Data|, DATA, READONLY
; an empty one, so the symbols below are always defined
......@@ -62,4 +68,8 @@ entriesStart
GET kernel.s.k_entries
entriesEnd
entries2Start
GET kernel.s.k_entries2
entries2End
LNK kernel.s.k_body
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*- Mode: Assembler -*-
;* Lastedit: 08 Mar 90 15:18:04 by Harry Meekings *
;* Shared C library: stub for clients to link with
; 2-Mar-89: IDJ: taken for RISC_OSLib purposes
;
; Copyright (C) Acorn Computers Ltd., 1988.
;
GBLL Brazil_Compatible
GBLL ModeMayBeNonUser
GBLL SharedLibrary
Brazil_Compatible SETL {FALSE}
ModeMayBeNonUser SETL {TRUE}
SharedLibrary SETL {TRUE}
GET s.h_Regs
GET s.h_Brazil
GET s.h_stubs
GET s.h_stack
GET s.h_workspc
AREA |Stub$$Init|, CODE, READONLY
& 4
& |_k_entries2_start|
& |_k_entries2_end|
& 0
& 0
AREA |Stub$$Entries|, CODE, READONLY
; Don't GET the stub entries if in ROM
GBLS GetRoundObjAsm
|_k_entries2_start|
[ Code_Destination = "RAM"
GetRoundObjAsm SETS " GET kernel.s.k_entries2"
|
GetRoundObjAsm SETS ""
]
$GetRoundObjAsm
|_k_entries2_end|
[ Code_Destination = "RAM" :LAND: APCS_Type <> "APCS-R"
% |_k_entries2_end| - |_k_entries2_start|
]
END
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GBLS Calling_Standard
Calling_Standard SETS "APCS_U"
GBLS Code_Destination
Code_Destination SETS "RAM"
LNK kernel.s.k_stub2
; Copyright 2002 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GBLS Calling_Standard
Calling_Standard SETS "APCS_U"
GBLS Code_Destination
Code_Destination SETS "ROM"
LNK kernel.s.k_stub2
......@@ -444,8 +444,11 @@ libdatasize_text
staticsizeok
]
SUB r3, r3, r2 ; size of library chunk statics
SUBS r3, r3, r2 ; size of library chunk statics
BLE NextLibraryChunk ; no statics for this chunk
; and the offset must agree with that for all earlier chunks
LDR r1, [r13, #Proc_RegOffset + 4]
LDR r1, [r1, #SC_SLOffset+SL_Client_Offset]
ADD r2, r2, r1 ; relocate address to copy to!!
......@@ -456,9 +459,6 @@ staticsizeok
BNE Failed
MOV r5, r1
CMP r3, #0
BLE NextLibraryChunk ; no statics for this chunk
; Copy the data from our fixed static data area to the clients dynamic
; static data area. No zero initialised data at all.
CopyLibStatics
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment