Skip to content

Commit

Permalink
Use stdint.h (#86)
Browse files Browse the repository at this point in the history
This removes our "own" custom types. Closes #6.
  • Loading branch information
perlun authored Oct 2, 2016
1 parent c73cc7f commit 54cfe96
Show file tree
Hide file tree
Showing 173 changed files with 1,780 additions and 1,787 deletions.
2 changes: 1 addition & 1 deletion documentation/coding-standards.fot
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
<a name="56"/>
<text> extern inline return_type system_call_thread_control
</text>
<text> (process_id_type process_id, u32 class, u32 parameter)
<text> (process_id_type process_id, uint32_t class, uint32_t parameter)
</text>
<text> </text>
<a name="57"/>
Expand Down
88 changes: 44 additions & 44 deletions documentation/coding-standards.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
</author>
<author>
<firstname>Anders</firstname>
<surname>�hrt</surname>
<surname>Öhrt</surname>
</author>
</authorgroup>
<pubdate>$Id$</pubdate>
</bookinfo>

<preface>
<title>Introduction</title>

<para>
This is The chaos Coding Standards. It is a guide in programming
for the chaos operating system. If you intend to submit your
Expand All @@ -31,17 +31,17 @@
code. It is very important to keep the same quality on all
code.
</para>

<para>
The code formatting chapters in this publication is mostly
C-related, but some of them can be used for other languages too.
</para>

</preface>

<chapter>
<title>Language choice</title>

<para>
Choosing the right language for a project is very important. If
you make a bad choice, it may render the program unusable for
Expand Down Expand Up @@ -70,7 +70,7 @@

<chapter>
<title>License choice</title>

<para>
chaos is a free operating system, as defined by the FSF, and as
such, all parts of it must be free. However, they do not have to
Expand Down Expand Up @@ -158,7 +158,7 @@
care about the warning, why don't you turn it off?
</para>
</chapter>

<chapter>
<title>Symbol names</title>

Expand Down Expand Up @@ -217,13 +217,13 @@

<programlisting>
/* Initialise the page allocation system. */

void page_init (void)
{
[...]
}
</programlisting>

<para>
As you see, we do not put the function name in the leftmost
column. There is no reason to do so. It just makes the code look
Expand All @@ -237,13 +237,13 @@

<programlisting>
extern inline return_type system_call_thread_control
(process_id_type process_id, u32 class, u32 parameter)
(process_id_type process_id, uint32_t class, uint32_t parameter)
</programlisting>
</chapter>

<chapter>
<title>Comments</title>

<para>
Code without comments is like an operating system without
applications -- it is not very usable. Try to comment your code
Expand Down Expand Up @@ -279,7 +279,7 @@
</para>

</chapter>

<chapter>
<title>Indentation</title>

Expand All @@ -288,7 +288,7 @@
tabs. When starting a new block, the braces should be on their own line
at the same level of indentation as the previous line, like this:
</para>

<programlisting>
if (age > LEGAL_AGE)
{
Expand All @@ -299,7 +299,7 @@

<chapter>
<title>Inline assembly</title>

<para>
Inline assembly is a twin-edged sword. It can make
computing-intensive programs a lot speedier, at the cost of
Expand Down Expand Up @@ -331,7 +331,7 @@
: "g" (buffer), "g" (parameter), "g" (class),
"n" (SYSTEM_CALL_KERNELFS_ENTRY_READ << 3));
</programlisting>

<para>
Do not write long blocks of uncommented inline assembly, but
keep it into functional blocks separated with blank lines and
Expand All @@ -341,7 +341,7 @@

<chapter>
<title>Miscellaneous</title>

<para>
Here you will find stuff that did not fit into one of the
previous chapters:
Expand All @@ -353,7 +353,7 @@
a block, even for one-line statements where it is not
required. Like this:
</para>

<programlisting>
if (age > LEGAL_AGE)
{
Expand All @@ -371,7 +371,7 @@
When writing switch statements, always use braces in the
case blocks. Like this:
</para>

<programlisting>
switch (key)
{
Expand All @@ -390,14 +390,14 @@
booleans. If something is not a boolean, you must compare
it with a number. Like this:
</para>

<programlisting>
if (get_age () != 0)
{
do_something ();
}
</programlisting>

<para>
This makes things much clearer. The lack of real booleans
in C is showing, but using this fact makes your programs
Expand All @@ -410,7 +410,7 @@
When declaring external functions (in library header files
and elsewhere), always write like this:
</para>

<programlisting>
extern my_function (void);
</programlisting>
Expand All @@ -423,10 +423,10 @@
</itemizedlist>
</para>
</chapter>

<chapter>
<title>Whitespace</title>

<para>
A lot of programmers tend to forget how important whitespace is
to write good code. A good example of this can be found in the
Expand All @@ -437,11 +437,11 @@
other places. Separate blocks of code with blank lines and
comments.
</para>
</chapter>
</chapter>

<chapter>
<title>Documentation</title>
<title>Documentation</title>

<para>
Documentation is essential for a program to succeed. All
documentation should be written in English (but may also be
Expand All @@ -451,10 +451,10 @@
the <ulink url="http://www.docbook.org">DocBook Web Site</ulink>.
</para>
</chapter>

<appendix>
<title>Examples</title>

<example>
<title>A C example</title>
<programlisting>
Expand Down Expand Up @@ -504,7 +504,7 @@ error_type semaphore_wait (kernel_semaphore_type *semaphore)
(*semaphore)--;
spin_unlock (semaphore_mutex);
}

return ERROR_UNKNOWN;
}

Expand All @@ -525,7 +525,7 @@ error_type semaphore_signal (kernel_semaphore_type *semaphore)
}
</programlisting>
</example>

<example>
<title>A Perl example</title>
<programlisting>
Expand Down Expand Up @@ -573,7 +573,7 @@ while (&lt;CONFIGFILE&gt;)
print ("Syntax error in config file: $_.\n");
exit;
}

my $flag = 1;

foreach my $config_key (keys %config_keyword)
Expand Down Expand Up @@ -616,17 +616,17 @@ cleanup ();

<appendix>
<title>Emacs settings for chaos indentation</title>

<para>
This is our .emacs settings for chaos indentation style for C
code. It makes writing compliant code much easier.
</para>

<programlisting>

;; chaos indentation style
(defconst chaos-c-style

(defconst chaos-c-style
'(
(c-basic-offset . 2)
(c-comment-only-line-offset . (0 . 0))
Expand All @@ -644,17 +644,17 @@ cleanup ();
)
"chaos"
)

(defun chaos-c-mode-common-hook ()

;; add my personal style and set it for the current buffer

(c-add-style "chaos" chaos-c-style t)

;; this will make sure spaces are used instead of tabs

(setq indent-tabs-mode nil))

(add-hook 'c-mode-common-hook 'chaos-c-mode-common-hook)
</programlisting>
</appendix>
Expand Down
2 changes: 1 addition & 1 deletion documentation/coding-standards.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ FORMAT="LINESPECIFIC"
</PARA><PROGRAMLISTING
FORMAT="LINESPECIFIC"
> extern inline return_type system_call_thread_control
(process_id_type process_id, u32 class, u32 parameter)
(process_id_type process_id, uint32_t class, uint32_t parameter)
</PROGRAMLISTING></CHAPTER><CHAPTER
><TITLE
>Comments</TITLE><PARA
Expand Down
12 changes: 6 additions & 6 deletions documentation/the_chaos_programming_reference_manual.texi
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ We do not use the errno approach at all, since it is very poor.
@node Section 2.2
@section The file library (library_file)

@deffn Function file_handle_type file_open (u8 *@var{file})
@deffn Function file_handle_type file_open (uint8_t *@var{file})
Opens the given file name and associates it with a file handle (which is used
when communicating to the VFS server). If the file does not exist, an error
will be returned.
Expand All @@ -175,17 +175,17 @@ Reads up to @var{size} bytes to @var{data} from the file handle associated with
@var{file}.
@end deffn

@deffn Function error_type file_create (u8 *@var{name})
@deffn Function error_type file_create (uint8_t *@var{name})
Creates a file with @var{name} as its full name (including path). Per default,
the file will be unaccessible by everybody but the owner; this may later be
changed by the @code{file_permissions_*} group of functions described later.
@end deffn

@deffn Function error_type file_permissions_delete_rule (u8 *@var{name}, acl_type @var{acl})
@deffn Function error_type file_permissions_delete_rule (uint8_t *@var{name}, acl_type @var{acl})
Deletes an ACL rule to the given file. Returns an error if this can't be done.
@end deffn

@deffn Function error_type file_permissions_add_rule (u8 *@var{name}, acl_type @var{acl})
@deffn Function error_type file_permissions_add_rule (uint8_t *@var{name}, acl_type @var{acl})
Adds an ACL rule to the given file. Returns an error if this can't be done.
@end deffn

Expand All @@ -200,11 +200,11 @@ TODO: More ACL stuff, do error number stuff.
@node Section 2.5
@section The console I/O library (library_console)

@deffn Function void console_print (u8 *@var{string})
@deffn Function void console_print (uint8_t *@var{string})
Prints @var{string} to the terminal owned by the program.
@end deffn

@deffn Function error_type console_print_formatted (u8 *@var{format_string}, ...)
@deffn Function error_type console_print_formatted (uint8_t *@var{format_string}, ...)
Prints @var{format_string}, replacing the type identifiers given
with the parameters added to the function call. The syntax is identical to
the ordinary ISO C @code{printf} function.
Expand Down
Loading

0 comments on commit 54cfe96

Please sign in to comment.