Ver código fonte

Fix the source code to reduce testsuite errors.

tags/v0.99.beta17
Sam Hocevar sam 16 anos atrás
pai
commit
3584efdf4b
8 arquivos alterados com 42 adições e 41 exclusões
  1. +16
    -17
      caca/codec/export.c
  2. +2
    -0
      kernel/Makefile.am
  3. +6
    -6
      kernel/kernel.c
  4. +5
    -7
      kernel/kernel.h
  5. +0
    -0
      kernel/klibc.h
  6. +9
    -9
      kernel/multiboot.h
  7. +3
    -2
      test/check-build
  8. +1
    -0
      win32/config.h

+ 16
- 17
caca/codec/export.c Ver arquivo

@@ -992,13 +992,12 @@ static void *export_tga(caca_canvas_t const *cv, size_t *bytes)
*/ */
static uint8_t _rgb_to_troff_index(uint32_t color) static uint8_t _rgb_to_troff_index(uint32_t color)
{ {
int i;
uint8_t r = 0;
for(i = 0; i < 3; i++)
{
r += ((color >> (8*i+7))&1) << i;
}
return r;
int i;
uint8_t r = 0;
for(i = 0; i < 3; i++)
r += ((color >> (8 * i + 7)) & 1) << i;

return r;
} }


/* Generate troff representation of current canvas. */ /* Generate troff representation of current canvas. */
@@ -1014,7 +1013,7 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)
uint32_t prevbg = 0; uint32_t prevbg = 0;
int started = 0; int started = 0;


/* Each char is at most
/* Each char is at most
* 2x\mM (2x10) * 2x\mM (2x10)
* + \fB + \fI + \fR (9) * + \fB + \fI + \fR (9)
* + 4 bytes = 33 * + 4 bytes = 33
@@ -1037,14 +1036,14 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)


for(x = 0; x < cv->width; x++) for(x = 0; x < cv->width; x++)
{ {
uint32_t fg = _rgb_to_troff_index(_caca_attr_to_rgb24fg(lineattr[x]));
uint32_t bg = _rgb_to_troff_index(_caca_attr_to_rgb24bg(lineattr[x]));
uint32_t ch = linechar[x];
if(fg != prevfg || !started)
cur += sprintf(cur, "\\m[%s]", colors[fg]);
if(bg != prevbg || !started)
cur += sprintf(cur, "\\M[%s]", colors[bg]);
uint32_t fg = _rgb_to_troff_index(_caca_attr_to_rgb24fg(lineattr[x]));
uint32_t bg = _rgb_to_troff_index(_caca_attr_to_rgb24bg(lineattr[x]));
uint32_t ch = linechar[x];
if(fg != prevfg || !started)
cur += sprintf(cur, "\\m[%s]", colors[fg]);
if(bg != prevbg || !started)
cur += sprintf(cur, "\\M[%s]", colors[bg]);
if(lineattr[x] & CACA_BOLD) if(lineattr[x] & CACA_BOLD)
cur += sprintf(cur, "\\fB"); cur += sprintf(cur, "\\fB");
if(lineattr[x] & CACA_ITALICS) if(lineattr[x] & CACA_ITALICS)
@@ -1061,7 +1060,7 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)
prevfg = fg; prevfg = fg;
prevbg = bg; prevbg = bg;
started = 1; started = 1;
}
}


/* Add unbreakable space at the end of lines, else spaces are dropped */ /* Add unbreakable space at the end of lines, else spaces are dropped */
if(x > 0 && linechar[x-1] == ' ') if(x > 0 && linechar[x-1] == ' ')


+ 2
- 0
kernel/Makefile.am Ver arquivo

@@ -20,3 +20,5 @@ clean: clean-local
clean-local: clean-local:
rm -f bootsect.bin kern.bin kernel.map rm -f bootsect.bin kern.bin kernel.map


echo-sources: ; echo $(SOURCES)


+ 6
- 6
kernel/kernel.c Ver arquivo

@@ -1,5 +1,5 @@
/* /*
* libcaca
* libcaca
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2006 Sam Hocevar <sam@hocevar.net> * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
* 2009 Jean-Yves Lamoureux <jylam@lnxscene.org> * 2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
@@ -34,17 +34,17 @@ int kmain(void)
{ {
struct processor_info processor_info; struct processor_info processor_info;
struct floppy_info floppy_info; struct floppy_info floppy_info;
printf("_start at 0x%x\n", _start); printf("_start at 0x%x\n", _start);
printf("kmain() at 0x%x\n", kmain); printf("kmain() at 0x%x\n", kmain);
printf("Types : char[%d] short[%d] int[%d] unsigned long long[%d]\n", sizeof(char), sizeof(short), sizeof(int), sizeof(unsigned long long)); printf("Types : char[%d] short[%d] int[%d] unsigned long long[%d]\n", sizeof(char), sizeof(short), sizeof(int), sizeof(unsigned long long));
enable_interrupt(1); // Enable Keyboard Interrupt (IRQ1) enable_interrupt(1); // Enable Keyboard Interrupt (IRQ1)
enable_interrupt(0); // Enable IRQ0 (timer) enable_interrupt(0); // Enable IRQ0 (timer)
enable_interrupt(13); enable_interrupt(13);
timer_phase(100); // Fire IRQ0 each 1/100s timer_phase(100); // Fire IRQ0 each 1/100s
processor_get_info(&processor_info); processor_get_info(&processor_info);
processor_print_info(&processor_info); processor_print_info(&processor_info);


@@ -53,7 +53,7 @@ int kmain(void)


/* Caca is delicious */ /* Caca is delicious */
printf("Filling memory with 0xCACA, starting from 0x%x\n", end); printf("Filling memory with 0xCACA, starting from 0x%x\n", end);
char *ptr = end; char *ptr = end;
while (1) while (1)
{ {


+ 5
- 7
kernel/kernel.h Ver arquivo

@@ -1,5 +1,5 @@
/* /*
* libcaca
* libcaca
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2006 Sam Hocevar <sam@hocevar.net> * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
* 2009 Jean-Yves Lamoureux <jylam@lnxscene.org> * 2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
@@ -26,13 +26,11 @@ void dump_gdt(void);
void disable_interrupt(char i); void disable_interrupt(char i);
void enable_interrupt(char i); void enable_interrupt(char i);


#define cli __asm__("cli" : : )
#define sti __asm__("sti" : : )


#define cli __asm__("cli"::)
#define sti __asm__("sti"::)

#define rdtsc(low,high) \
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))

#define rdtsc(low, high) \
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))


/* The application's entry point */ /* The application's entry point */
int main(int argc, char *argv[]); int main(int argc, char *argv[]);


+ 0
- 0
kernel/klibc.h Ver arquivo


+ 9
- 9
kernel/multiboot.h Ver arquivo

@@ -1,16 +1,16 @@
/* multiboot.h - the header for Multiboot */ /* multiboot.h - the header for Multiboot */
/* Copyright (C) 1999 Free Software Foundation, Inc. /* Copyright (C) 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
@@ -18,22 +18,22 @@
/* Macros. */ /* Macros. */


/* The magic number for the Multiboot header. */ /* The magic number for the Multiboot header. */
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002


/* The flags for the Multiboot header. */ /* The flags for the Multiboot header. */
#define MULTIBOOT_HEADER_FLAGS 0x00010003
#define MULTIBOOT_HEADER_FLAGS 0x00010003


/* The magic number passed by a Multiboot-compliant boot loader. */ /* The magic number passed by a Multiboot-compliant boot loader. */
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002


/* The size of our stack (16KB). */ /* The size of our stack (16KB). */
#define STACK_SIZE 0x4000
#define STACK_SIZE 0x4000


/* C symbol format. HAVE_ASM_USCORE is defined by configure. */ /* C symbol format. HAVE_ASM_USCORE is defined by configure. */
#ifdef HAVE_ASM_USCORE #ifdef HAVE_ASM_USCORE
# define EXT_C(sym) _ ## sym
# define EXT_C(sym) _ ## sym
#else #else
# define EXT_C(sym) sym
# define EXT_C(sym) sym
#endif #endif


#ifndef ASM #ifndef ASM


+ 3
- 2
test/check-build Ver arquivo

@@ -27,7 +27,7 @@ fi
# Check that we have no tabs or trailing spaces in the source code # Check that we have no tabs or trailing spaces in the source code
# #
failure=0 failure=0
for dir in caca src cxx examples ruby tools; do
for dir in caca kernel src cxx examples ruby tools; do
pushd ../$dir >/dev/null pushd ../$dir >/dev/null
for x in $(make -s echo-sources); do for x in $(make -s echo-sources); do
case "$x" in case "$x" in
@@ -56,7 +56,8 @@ fi
# #
warnings="$(grep -c Warning: ../doc/doxygen.log)" warnings="$(grep -c Warning: ../doc/doxygen.log)"
if test "$warnings" != "0"; then if test "$warnings" != "0"; then
echo "error: $warnings warnings in Doxygen generation"
echo "error: $warnings warnings in Doxygen generation:"
grep Warning: ../doc/doxygen.log | sed 's/\(.\{75\}\)...*/\1 .../'
ret=1 ret=1
else else
echo "0 errors in documentation" echo "0 errors in documentation"


+ 1
- 0
win32/config.h Ver arquivo

@@ -25,6 +25,7 @@
/* #undef HAVE_IMLIB2_H */ /* #undef HAVE_IMLIB2_H */
/* #undef HAVE_INTTYPES_H */ /* #undef HAVE_INTTYPES_H */
/* #undef HAVE_IOCTL */ /* #undef HAVE_IOCTL */
/* #undef HAVE_JNI_H */
/* #undef HAVE_LOCALE_H */ /* #undef HAVE_LOCALE_H */
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
/* #undef HAVE_NCURSESW_NCURSES_H */ /* #undef HAVE_NCURSESW_NCURSES_H */


Carregando…
Cancelar
Salvar