Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alp4-repo-template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teaching Stuff
alp4
alp4-repo-template
Commits
bb52e634
Verified
Commit
bb52e634
authored
2 years ago
by
abrahas55
Browse files
Options
Downloads
Patches
Plain Diff
added asm-example branch for CA
parent
842f1e2b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+14
-6
14 additions, 6 deletions
Makefile
README.md
+11
-9
11 additions, 9 deletions
README.md
example.c
+0
-52
0 additions, 52 deletions
example.c
wrapper.c
+25
-0
25 additions, 0 deletions
wrapper.c
with
50 additions
and
67 deletions
Makefile
+
14
−
6
View file @
bb52e634
NASM
=
nasm
NASMFLAGS
=
-f
elf64
CC
=
gcc
CC
=
gcc
CFLAGS
=
-std
=
c11
-Wall
-Wextra
-pedantic
-O2
-g
-pthread
CFLAGS
=
-std
=
c11
-Wall
-Wextra
-pedantic
-O2
-g
#CPPFLAGS = -MMD -MF $*.d #activate only if you want extra output as .d files
#CPPFLAGS = -MMD -MF $*.d #activate only if you want extra output as .d files
# TODO: edit BIN with your target binary (e.g. exercise01)
# TODO: edit BIN with your target binary (e.g. exercise01)
BIN
=
example
BIN
=
example
OBJS
=
$(
BIN
)
.o
OBJS
=
$(
BIN
)
.o
wrapper.o
all
:
$(BIN)
all
:
$(BIN)
$(BIN)
:
$(OBJS)
# uncomment this if you want object files
%
:
%.o
#$(BIN): $(OBJS)
$(
CC
)
-o
$@
$(
LDFLAGS
)
$^
$(
LDLIBS
)
%.o
:
%.asm
$(
NASM
)
-o
$@
$(
NASMFLAGS
)
$<
%.o
:
%.c
$(
CC
)
-c
-o
$@
$(
CPPFLAGS
)
$(
CFLAGS
)
$<
run
:
$(BIN)
run
:
$(BIN)
./
$(
BIN
)
./
$(
BIN
)
# define test cases here
#
TODO:
define test cases here
test1
:
$(BIN)
test1
:
$(BIN)
./
$(
BIN
)
5
./
$(
BIN
)
5
test2
:
$(BIN)
test2
:
$(BIN)
...
...
This diff is collapsed.
Click to expand it.
README.md
+
11
−
9
View file @
bb52e634
# ALP4 repository template --
C
# ALP4 repository template --
ASM
Use this template for the ALP4 course. This branch should be used for C
This branch should be used for ASM exercises (not relevant to ALP4).
exercises.
## How to build
## How to build
...
@@ -9,14 +8,17 @@ This example uses Make, see the
...
@@ -9,14 +8,17 @@ This example uses Make, see the
[
documentation
](
https://www.gnu.org/software/make/manual/make.html
)
[
documentation
](
https://www.gnu.org/software/make/manual/make.html
)
for more information on how to use it.
for more information on how to use it.
## Submission
### Makefile
Edit the Makefile according to your exercise, correct the name for your binary
and the wrapper (or rename the given wrapper file to wrapper.c).
Also don't forget to add test cases.
In Whiteboard, add the corresponding commit hash in the comment field of the
## Submission
exercise.
Keep in mind this is specific to the course in Summer 2022!
Submit everything in this repo, you are also welcome to submit pdf's in
whiteboard.
## Contributions
## Contributions
Feel free to open issues or submit merge requests for changes. Also you could
Feel free to open issues or submit merge requests for changes.
fork this to prepare templates for other courses.
This diff is collapsed.
Click to expand it.
example.c
deleted
100644 → 0
+
0
−
52
View file @
842f1e2b
/*
* small example showing how to use pthreads
*
* will print output until user ends program with either Ctrl-C
*
* for more information check out 'man 7 pthreads' and corresponding manpages
* from chapter 3
*/
#include
<stdlib.h>
#include
<stdio.h>
#include
<unistd.h>
#include
<inttypes.h>
#include
<pthread.h>
void
*
start_routine
(
void
*
arg
)
{
(
void
)
arg
;
pthread_t
pid
=
pthread_self
();
for
(
size_t
i
=
0
;
i
<
50
;
i
++
)
{
printf
(
"i am thread %lu
\n
"
,
pid
);
sleep
(
1
);
}
pthread_exit
(
EXIT_SUCCESS
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
(
void
)
argc
;
(
void
)
argv
;
// ignore this, just to suppress warnings
long
unsigned
int
thread_ids
[
6
];
size_t
amount_threads
=
5
;
for
(
size_t
i
=
0
;
i
<
amount_threads
;
i
++
)
{
// we do no error checking!
pthread_create
(
&
thread_ids
[
i
],
NULL
,
// default attributes
&
start_routine
,
// what should the thread do
NULL
// no arguments for the thread
);
}
// either do this for lazy or join the threads together
while
(
1
)
{
puts
(
"main!"
);
sleep
(
1
);
}
return
EXIT_SUCCESS
;;
}
This diff is collapsed.
Click to expand it.
wrapper.c
0 → 100644
+
25
−
0
View file @
bb52e634
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdbool.h>
#include
<inttypes.h>
extern
uint64_t
collatz
(
uint64_t
);
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
fputs
(
"Not enough arguments!
\n
"
,
stderr
);
return
EXIT_FAILURE
;
}
char
*
test
=
NULL
;
uint64_t
val
=
strtoull
(
argv
[
1
],
&
test
,
10
);
if
(
*
test
)
{
fprintf
(
stderr
,
"Invalid Argument: %s
\n
"
,
argv
[
1
]);
return
EXIT_FAILURE
;
}
uint64_t
res
=
collatz
(
val
);
printf
(
"collatz(%"
PRIu64
") = %"
PRIu64
"
\n
"
,
val
,
res
);
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment