generated from RISC-OS-Community/StandardRepoTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DDE example in C and fixed a minor bug in the build process
- Loading branch information
Showing
17 changed files
with
323 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* Name: ZVector_Checks | ||
* Purpose: Header used by ZVector Library to identify for which | ||
* platform ZVector is being compiled. | ||
* Author: Paolo Fabio Zaino | ||
* Domain: General | ||
* License: Copyright 2021 by Paolo Fabio Zaino, all rights reserved | ||
* Distributed under MIT license | ||
* | ||
*/ | ||
|
||
#ifndef SRC_ZVECTOR_CHECKS_H_ | ||
#define SRC_ZVECTOR_CHECKS_H_ | ||
|
||
// Try to determine the Operating System being used: | ||
#if defined(__APPLE__) && defined(__MACH__) | ||
# define macOS | ||
#endif | ||
|
||
#if ( defined(__GNU__) || defined(__gnu_linux__) || \ | ||
defined(__linux__) || defined(macOS) ) | ||
# define OS_TYPE 1 | ||
#elif ( defined(__WIN32__) || defined(WIN32) || defined(_WIN32) ) | ||
# define OS_TYPE 2 | ||
#else | ||
# define OS_TYPE 0 | ||
#endif | ||
|
||
// Try to determine compiler being used: | ||
#if defined(__GNUC__) | ||
# define compiler gcc | ||
# define ZVECT_COMPTYPE 1 | ||
# define COMP_MAJRELEASE (__GNUC__) | ||
# define COMP_MINRELEASE (__GNUC_MINOR__) | ||
# define COMP_PATRELEASE (__GNUC_PATCHLEVEL__) | ||
#elif defined(__NORCROFT_C__) || defined(__CC_NORCROFT) || \ | ||
defined(__ARMCC_VERSION) | ||
// For Norcroft C please remember to specify: | ||
// -c99 | ||
# define compiler norcroftc | ||
# define ZVECT_COMPTYPE 6 | ||
# define COMP_MAJRELEASE (__ARMCC_VERSION) | ||
# define _MSC_VER 0 | ||
#elif defined(_MSC_VER) | ||
# define compiler msc | ||
# define ZVECT_COMPTYPE 2 | ||
# define COMP_MAJRELEASE (_MSC_VER) | ||
# define COMP_MINRELEASE 0 | ||
# define COMP_PATRELEASE 0 | ||
#elif defined(__clang__) | ||
# define compiler clang | ||
# define ZVECT_COMPTYPE 3 | ||
# define COMP_MAJRELEASE (__clang_major__) | ||
# define COMP_MINRELEASE (__clang_minor__) | ||
# define COMP_PATRELEASE (__clang_patchlevel__) | ||
#elif defined(__INTEL_COMPILER) || defined(__ICC) || \ | ||
defined(__ECC) || defined(__ICL) | ||
// For intel c compiler please remember to specify: | ||
// /Qstd=c99 (on Windows) | ||
// -std=c99 on Linux and/or macOS | ||
# define compiler intelc | ||
# define ZVECT_COMPTYPE 4 | ||
# define COMP_MAJRELEASE (__INTEL_COMPILER) | ||
# define COMP_MINRELEASE 0 | ||
# define COMP_PATRELEASE 0 | ||
#elif defined (__LCC__) | ||
# define compiler lcc | ||
# define ZVECT_COMPTYPE 5 | ||
# define COMP_MAJRELEASE (__LCC) | ||
# define COMP_MINRELEASE 0 | ||
# define COMP_PATRELEASE 0 | ||
#elif defined(_CRAYC) | ||
// For Cray C please remember to specify: | ||
// -hc99 | ||
# define compiler crayc | ||
# define ZVECT_COMPTYPE 10 | ||
# define COMP_MAJRELEASE (_RELEASE) | ||
# define COMP_MINRELEASE (_RELEASE_MINOR) | ||
# define COMP_PATRELEASE 0 | ||
#elif defined(__HP_cc) | ||
// For HP CC please remember to specify: | ||
// -ansi -std=c99 | ||
# define compiler hpc | ||
# define ZVECT_COMPTYPE 11 | ||
# define COMP_MAJRELEASE 1 | ||
# define COMP_MINRELEASE 21 | ||
# define COMP_PATRELEASE 0 | ||
#elif defined(__IBMC__) | ||
// For IBM C please remember to specify: | ||
// C99 flags | ||
# define compiler ibmc | ||
# define ZVECT_COMPTYPE 12 | ||
#elif defined(__TINYC__) | ||
# define compiler tinyc | ||
# define ZVECT_COMPTYPE 6 | ||
# define COMP_MAJRELEASE 0 | ||
# define COMP_MINRELEASE 0 | ||
# define COMP_PATRELEASE 0 | ||
#else | ||
# define compiler unknown | ||
# define ZVECT_COMPTYPE 0 | ||
#endif | ||
#if defined(_MSC_VER) && (_MSC_VER >= 1020) | ||
#pragma once | ||
#endif | ||
|
||
// Try to determine CPU Architecture: | ||
#define ARM32 0 | ||
#define ARM64 1 | ||
#define x86_64 2 | ||
#define unknown -1 | ||
#if defined(__aarch64__) | ||
# define CPU_TYPE ARM64 | ||
# define Arch64 | ||
#elif defined(__aarch32__) | ||
# define CPU_TYPE ARM32 | ||
# define Arch32 | ||
#elif defined(__amd64__) || defined(__x86_64__) || \ | ||
defined(__ia64__) || defined(_M_IA64) || \ | ||
defined(_M_AMD64) || defined(_M_X64) | ||
# define CPU_TYPE x86_64 | ||
# define Arch64 | ||
#else | ||
# define CPU_TYPE unknown | ||
# define Arch32 | ||
#endif | ||
|
||
// Start setting up macros based on the platform we detected | ||
// above. | ||
|
||
#if ( OS_TYPE == 1 ) | ||
// We are on a Unix-like OS so we can use pthreads! | ||
# define MUTEX_TYPE 1 | ||
# elif ( OS_TYPE == 2 ) && ( defined(__CYGWIN__) || \ | ||
defined(__MINGW32__) || defined(__MINGW64__) ) | ||
// We are on MS Windows using CIGWIN so we can use pthreads! | ||
# define MUTEX_TYPE 1 | ||
# elif ( OS_TYPE == 2 ) && ( !defined(__CYGWIN__) && \ | ||
!defined(__MINGW32__) && !defined(__MINGW64__) ) | ||
// We are on MS Windows, so we need to use | ||
// Windows stuff: | ||
# define MUTEX_TYPE 2 | ||
#else | ||
// I have no idea on which platform are we, | ||
// hence I have to use fake mutexes and go with the flow! | ||
# define MUTEX_TYPE 0 | ||
#endif | ||
|
||
#endif // SRC_ZVECTOR_CHECKS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Name: Vector_config | ||
* Purpose: Base configuration for the ZVector library | ||
* Author: Paolo Fabio Zaino | ||
* Domain: General | ||
* License: Copyright by Paolo Fabio Zaino, all rights reserved | ||
* Distributed under MIT license | ||
* | ||
*/ | ||
|
||
#ifndef SRC_ZVECTOR_CONFIG_H_ | ||
#define SRC_ZVECTOR_CONFIG_H_ | ||
#if defined(_MSC_VER) && (_MSC_VER >= 1020) | ||
#pragma once | ||
#endif | ||
|
||
// Include some standard C lib header | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
// Data alignment configuration | ||
#if ( ZVECT_COMPTYPE == 1 ) | ||
#define ZVECT_DATAALIGN __attribute__((aligned)) | ||
#define ZVECT_PACKING __attribute__((__packed__)) | ||
#define ZVECT_ALWAYSINLINE __attribute__ ((__always_inline__)) | ||
#else | ||
#define ZVECT_DATAALIGN | ||
#define ZVECT_PACKING | ||
#define ZVECT_ALWAYSINLINE | ||
#endif | ||
|
||
// Default vector Index type | ||
// This is set to unsigned int of 32bit | ||
// size (so all different architectures | ||
// and OS behaves in a similar way) | ||
// If you want a larger index you can | ||
// change it to, for example, uint64_t | ||
typedef uint32_t zvect_index; | ||
#define zvect_index_max UINT32_MAX // If you change zvect_index type make sure you update this value | ||
// it's the maximum number that can be stored in a zvect_index. | ||
|
||
// Default vector return type for | ||
// error codes. | ||
// Generally negative numbers identify | ||
// an error. | ||
// 0 identify completed successful | ||
// Positive numbers identify return | ||
// attributes, like 1 is generally true | ||
typedef int32_t zvect_retval; | ||
|
||
// Default vector storage size | ||
// This will be used when the user | ||
// specifies 0 (zero) as data type | ||
// size. | ||
#define ZVECT_DEFAULT_DATA_SIZE sizeof(int) | ||
|
||
// Default vector capacity | ||
// This will be used when the user | ||
// does NOT specify an Initial Capacity | ||
// or set it to 0 (zero): | ||
#define ZVECT_INITIAL_CAPACITY 8 | ||
|
||
// The following options are handled by Make | ||
// So you should not need to modify them here. | ||
|
||
// Choose which type of memory functions you want | ||
// to use for your case: | ||
// 0 = Use Standard memcpy and memmove | ||
// 1 = Use Optimized memcpy and memmove | ||
#define ZVECT_MEMX_METHOD 0 | ||
|
||
// Enable/Disable thread safe code: | ||
#define ZVECT_THREAD_SAFE 0 | ||
|
||
// Enable/Disable reentrant code: | ||
#define ZVECT_FULL_REENTRANT 0 | ||
|
||
// Enable/Disable DMF Extensions: | ||
#define ZVECT_DMF_EXTENSIONS 1 | ||
|
||
// Enable/Disable SFMD Extensions: | ||
#define ZVECT_SFMD_EXTENSIONS 1 | ||
|
||
// If you are using ZVector on a system | ||
// that supports cooperative multitasking | ||
// (like RISC OS or some embedded systems) | ||
// then uncomment the following line: | ||
//#define ZVECT_COOPERATIVE | ||
|
||
#endif // SRC_ZVECTOR_CONFIG_H_ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Makefile for exampleapp | ||
|
||
COMPONENT = exampleapp | ||
|
||
# The name of the linked file defaults to COMPONENT, which is often the case | ||
# for single-file programs. But when the linked file lives in an application | ||
# directory, it is normally called !RunImage. | ||
TARGET = !RunImage | ||
|
||
# The list of source/object files defaults to TARGET, which again is often | ||
# the case for single-file programs. But we don't want our source file to be | ||
# called !RunImage. | ||
OBJS = main | ||
|
||
INSTDIR ?= <Obey$Dir> | ||
|
||
# The shared makefiles don't attempt to guess the application directory name | ||
# Usually you'll want to place it inside INSTDIR, which is passed in from | ||
# either the MkInstall file, or (for !Builder builds) the components file. | ||
# SEP expands to the directory separator character - we use this instead of | ||
# a literal '.' character to help with cross-compilation. | ||
INSTAPP = ${INSTDIR}${SEP}!Example | ||
|
||
# You need to specify all the files that go into the application directory. | ||
# The shared makefiles handle merging the various subdirectories of the | ||
# Resources directory for you. | ||
INSTAPP_FILES = !Boot !Run !Sprites !Sprites11 !Sprites22 !RunImage | ||
|
||
include CApp | ||
CINCLUDES += -ILibZVector:zvector.h | ||
LIBS += LibZVector:o.zvectorlib | ||
|
||
clean:: | ||
${WIPE} ${INSTAPP} ${WFLAGS} | ||
|
||
# Dynamic dependencies: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dir <Obey$Dir> | ||
WimpSlot -min 1024k | ||
amu all THROWBACK=-throwback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dir <Obey$Dir> | ||
amu clean | ||
stripdepnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dir <Obey$Dir> | ||
amu debug THROWBACK=-throwback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dir <Obey$Dir> | ||
amu install INSTTYPE=app INSTDIR=<Obey$Dir> USERIF=Iyonix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| !Boot files are normally locale-independent | ||
IconSprites <Obey$Dir>.!Sprites |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
| !Run files are normally locale-dependent, if only for the error messages | ||
|
||
RMEnsure UtilityModule 3.10 Error This application requires RISC OS 3.10 or later | ||
RMEnsure UtilityModule 5.00 RMEnsure CallASWI 0.03 RMLoad System:Modules.CallASWI | ||
RMEnsure UtilityModule 5.00 RMEnsure CallASWI 0.03 Error This app requires CallASWI 0.03 or later | ||
RMEnsure FPEmulator 4.03 RMLoad System:Modules.FPEmulator | ||
RMEnsure FPEmulator 4.03 Error This application requires FPEmulator 4.03 or later | ||
RMEnsure SharedCLibrary 5.17 RMLoad System:Modules.CLib | ||
RMEnsure SharedCLibrary 5.34 Error This application requires SharedCLibrary 5.34 or later | ||
|
||
Run <Obey$Dir>.!RunImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include "LibZVector:zvector.h" | ||
|
||
int main(void) | ||
{ | ||
vector v = vect_create(16, sizeof(int), ZV_SEC_WIPE); | ||
|
||
for (int i = 1; i <= 10; i++) | ||
vect_add(v, &i); | ||
|
||
for (int i=1; i <= 10; i++) | ||
{ | ||
int *val = (int *)vect_pop(v); | ||
printf ("Value %d: %d\n", i, *val); | ||
} | ||
|
||
vect_destroy(v); | ||
exit(EXIT_SUCCESS); | ||
} |