aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/modules/hello.c
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-08-11 19:22:29 +0300
committerStefan Bucur <stefan@stefan-ubumac.(none)>2009-03-15 10:10:50 +0200
commit9195aa5d71b5593742fcae9957e2e9328717fb12 (patch)
tree92743c40530ba52d78b81040eee1bb1110a38180 /com32/elflink/modules/hello.c
parentfac2992f2848ce2a630ba03f3a9f43d5928297ae (diff)
downloadsyslinux-elf-9195aa5d71b5593742fcae9957e2e9328717fb12.tar.gz
syslinux-elf-9195aa5d71b5593742fcae9957e2e9328717fb12.tar.xz
syslinux-elf-9195aa5d71b5593742fcae9957e2e9328717fb12.zip
Created a simple quick sort module.
Diffstat (limited to 'com32/elflink/modules/hello.c')
-rw-r--r--com32/elflink/modules/hello.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/com32/elflink/modules/hello.c b/com32/elflink/modules/hello.c
index d1054a1f..2386ecb3 100644
--- a/com32/elflink/modules/hello.c
+++ b/com32/elflink/modules/hello.c
@@ -1,14 +1,49 @@
/*
- * The first prototype of an ELF module, inspired from the Linux kernel
- * module system.
+ * hello.c - A simple ELF module that sorts a couple of numbers
+ *
+ * Created on: Aug 11, 2008
+ * Author: Stefan Bucur <stefanb@zytor.com>
*/
#include <stdio.h>
+#include <stdlib.h>
#include <sys/module.h>
+#include "sort.h"
+
+
+#define NUM_COUNT 10
+#define MAX_NUM 100
+
static int hello_init(void) {
+ int *nums = NULL;
+ int i;
+
printf("Hello, world, from 0x%08X!\n", (unsigned int)&hello_init);
+
+ nums = malloc(NUM_COUNT*sizeof(int));
+
+ for (i = 0; i < NUM_COUNT; i++) {
+ nums[i] = rand() % MAX_NUM;
+ }
+
+ printf("Numbers before sort: ");
+ for (i = 0; i < NUM_COUNT; i++) {
+ printf("%d ", nums[i]);
+ }
+ printf("\n");
+
+ quick_sort(nums, NUM_COUNT);
+
+ printf("Numbers after sort: ");
+ for (i = 0; i < NUM_COUNT; i++) {
+ printf("%d ", nums[i]);
+ }
+ printf("\n");
+
+ free(nums);
+
return 0;
}