Skip to content

Commit

Permalink
fix code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Jan 26, 2025
1 parent d4b6e74 commit 09d9368
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(stddef.h HAVE_STDDEF_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdbool.h HAVE_STDBOOL_H)

if (OPT_FORMAT_ABGR)
set(ENABLE_FORMAT_ABGR 1)
Expand Down
16 changes: 15 additions & 1 deletion build/pconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,22 @@

/* Define if System memory allocator is supported. */
#cmakedefine ENABLE_SYSTEM_MALLOC @ENABLE_SYSTEM_MALLOC@

/* Have stdint.h */
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@

/* Have stdlib.h */
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@

/* Have stddef.h */
#cmakedefine HAVE_STDDEF_H @HAVE_STDDEF_H@

/* Have stdbool.h */
#cmakedefine HAVE_STDBOOL_H @HAVE_STDBOOL_H@

/* Have string.h */
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@

/* Have memory.h */
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@
#endif /*_CONFIGURATION_HEADER_PCONFIG_H_*/
48 changes: 48 additions & 0 deletions ext/common/psx_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, Zhang Ji Peng
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _PSX_COMMON_H_
#define _PSX_COMMON_H_

#include "pconfig.h"

#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
typedef int bool;
#define true 1;
#define false 0;
#endif

#if defined(__GNUC__)
#define INLINE inline
#elif defined(_MSC_VER)
#define INLINE __inline
#else
#define INLINE
#endif

#endif /*_PSX_COMMON_H_*/
12 changes: 3 additions & 9 deletions ext/common/psx_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
#ifndef _PSX_LIST_H_
#define _PSX_LIST_H_

#if defined(__GNUC__)
#define INLINE inline
#elif defined(_MSC_VER)
#define INLINE __inline
#else
#define INLINE
#endif
#include "psx_common.h"

struct list_hdr {
struct list_hdr* next;
Expand All @@ -48,9 +42,9 @@ static INLINE void list_init(struct list_hdr* head)
head->prev = head;
}

static INLINE int list_empty(const struct list_hdr* head)
static INLINE bool list_empty(const struct list_hdr* head)
{
return head->next == head ? 0 : -1;
return head->next == head;
}

#define list_add(head, value) \
Expand Down
2 changes: 1 addition & 1 deletion ext/image_coders/psx_image_modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int psx_image_unregister_operator(psx_image_operator* coder)
return S_INIT_FAILURE;
}

if (list_empty(&(mgr->coders)) == 0) {
if (list_empty(&(mgr->coders))) {
return S_OK;
}

Expand Down

0 comments on commit 09d9368

Please sign in to comment.