Skip to content

Commit

Permalink
Fixed Linux build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-manias committed Apr 1, 2024
1 parent 0992e34 commit 96268d7
Show file tree
Hide file tree
Showing 39 changed files with 394 additions and 543 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,6 @@ if (NOT DISABLE_VECTOR AND NOT DISABLE_DISPLAY AND NOT DISABLE_FONT)
list (APPEND LIB_LIST vector)
endif ()

if (X11_Xrandr_FOUND)
add_subdirectory (src/xrandr)
list (APPEND LIB_LIST xrandr)
endif ()

list (APPEND LIB_LIST fluid json jpeg xml)

add_subdirectory (src/link)
Expand Down
6 changes: 6 additions & 0 deletions docs/xml/modules/display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,5 +1238,11 @@ Alpha = CFUnpackAlpha(Format,Colour)
<field name="LineWidth" type="LONG">Line width of the bitmap, in bytes</field>
</struct>

<struct name="xrMode" comment="Display mode.">
<field name="Width" type="LONG">Horizontal</field>
<field name="Height" type="LONG">Vertical</field>
<field name="Depth" type="LONG">bit depth</field>
</struct>

</structs>
</book>
4 changes: 2 additions & 2 deletions docs/xml/modules/fluid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<function>
<name>SetVariable</name>
<comment>Sets any variable in a loaded Fluid script.</comment>
<prototype>ERROR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, ...)</prototype>
<prototype>ERR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, ...)</prototype>
<input>
<param type="OBJECTPTR" name="Script">Pointer to a Fluid script.</param>
<param type="CSTRING" name="Name">The name of the variable to set.</param>
Expand All @@ -25,7 +25,7 @@
<description>
<p>The SetVariable() function provides a method for setting global variables in a Fluid script prior to execution of that script. If the script is cached, the variable settings will be available on the next activation.</p>
</description>
<result type="ERROR">
<result type="ERR">
<error code="Okay">Operation successful.</error>
<error code="Args">Invalid arguments passed to function.</error>
<error code="ObjectCorrupt">The object structure is corrupt or has not been initialised.</error>
Expand Down
4 changes: 2 additions & 2 deletions docs/xml/modules/xrandr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
<function>
<name>SetDisplayMode</name>
<comment>Change the width and height of the display.</comment>
<prototype>ERROR xrSetDisplayMode(LONG * Width, LONG * Height)</prototype>
<prototype>ERR xrSetDisplayMode(LONG * Width, LONG * Height)</prototype>
<input>
<param type="LONG *" name="Width">The required width of the display.</param>
<param type="LONG *" name="Height">The required height of the display.</param>
</input>
<description>
<p>This function changes the width and height of the display to that indicated by the Width and Height parameters. If the requested size does not match a known mode, the closest matching mode will be chosen.</p>
</description>
<result type="ERROR">
<result type="ERR">
<error code="Okay">Operation successful.</error>
</result>
</function>
Expand Down
6 changes: 6 additions & 0 deletions include/parasol/modules/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ struct SurfaceCoords {
LONG AbsY; // Absolute Y
};

struct xrMode {
LONG Width; // Horizontal
LONG Height; // Vertical
LONG Depth; // bit depth
};

typedef struct PixelFormat {
UBYTE RedShift; // Right shift value
UBYTE GreenShift; // Green shift value
Expand Down
6 changes: 3 additions & 3 deletions include/parasol/modules/fluid.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

struct FluidBase {
#ifndef PARASOL_STATIC
ERROR (*_SetVariable)(OBJECTPTR Script, CSTRING Name, LONG Type, ...);
ERR (*_SetVariable)(OBJECTPTR Script, CSTRING Name, LONG Type, ...);
#endif // PARASOL_STATIC
};

#ifndef PRV_FLUID_MODULE
#ifndef PARASOL_STATIC
extern struct FluidBase *FluidBase;
template<class... Args> ERROR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, Args... Tags) { return FluidBase->_SetVariable(Script,Name,Type,Tags...); }
template<class... Args> ERR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, Args... Tags) { return FluidBase->_SetVariable(Script,Name,Type,Tags...); }
#else
extern "C" {
extern ERROR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, ...);
extern ERR flSetVariable(OBJECTPTR Script, CSTRING Name, LONG Type, ...);
}
#endif // PARASOL_STATIC
#endif
Expand Down
24 changes: 21 additions & 3 deletions include/parasol/modules/xrandr.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,39 @@

#define MODVERSION_XRANDR (1)

extern struct XRandRBase *XRandRBase;
#ifdef PARASOL_STATIC
#define JUMPTABLE_XRANDR static struct XRandRBase *XRandRBase;
#else
#define JUMPTABLE_XRANDR struct XRandRBase *XRandRBase;
#endif

struct XRandRBase {
ERROR (*_SetDisplayMode)(LONG * Width, LONG * Height);
#ifndef PARASOL_STATIC
ERR (*_SetDisplayMode)(LONG * Width, LONG * Height);
LONG (*_Notify)(APTR XEvent);
void (*_SelectInput)(LONG Window);
LONG (*_GetDisplayTotal)(void);
APTR (*_GetDisplayMode)(LONG Index);
#endif // PARASOL_STATIC
};

#ifndef PRV_XRANDR_MODULE
inline ERROR xrSetDisplayMode(LONG * Width, LONG * Height) { return XRandRBase->_SetDisplayMode(Width,Height); }
#ifndef PARASOL_STATIC
extern struct XRandRBase *XRandRBase;
inline ERR xrSetDisplayMode(LONG * Width, LONG * Height) { return XRandRBase->_SetDisplayMode(Width,Height); }
inline LONG xrNotify(APTR XEvent) { return XRandRBase->_Notify(XEvent); }
inline void xrSelectInput(LONG Window) { return XRandRBase->_SelectInput(Window); }
inline LONG xrGetDisplayTotal(void) { return XRandRBase->_GetDisplayTotal(); }
inline APTR xrGetDisplayMode(LONG Index) { return XRandRBase->_GetDisplayMode(Index); }
#else
extern "C" {
extern ERR xrSetDisplayMode(LONG * Width, LONG * Height);
extern LONG xrNotify(APTR XEvent);
extern void xrSelectInput(LONG Window);
extern LONG xrGetDisplayTotal(void);
extern APTR xrGetDisplayMode(LONG Index);
}
#endif // PARASOL_STATIC
#endif

struct xrMode {
Expand Down
8 changes: 4 additions & 4 deletions src/audio/alsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static ERR init_audio(extAudio *Self)
cardid = (STRING)snd_ctl_card_info_get_id(info);
cardname = (STRING)snd_ctl_card_info_get_name(info);

if (!StrMatch(cardid, pcm_name.c_str())) {
if (StrMatch(cardid, pcm_name.c_str()) IS ERR::Okay) {
pcm_name = name;
snd_ctl_close(ctlhandle);
break;
Expand All @@ -81,7 +81,7 @@ static ERR init_audio(extAudio *Self)
// Check if the default ALSA device is a real sound card. We don't want to use it if it's a modem or other
// unexpected device.

if (!StrMatch("default", pcm_name.c_str())) {
if (StrMatch("default", pcm_name.c_str()) IS ERR::Okay) {
// If there are no sound devices in the system, abort

LONG card = -1;
Expand All @@ -106,7 +106,7 @@ static ERR init_audio(extAudio *Self)

log.msg("Identified card %s, name %s", cardid, cardname);

if (!StrMatch("modem", cardid)) goto next_card;
if (StrMatch("modem", cardid) IS ERR::Okay) goto next_card;

snd_mixer_t *mixhandle;
if ((err = snd_mixer_open(&mixhandle, 0)) >= 0) {
Expand Down Expand Up @@ -410,7 +410,7 @@ static ERR init_audio(extAudio *Self)

if (Self->AudioBuffer) { FreeResource(Self->AudioBuffer); Self->AudioBuffer = NULL; }

if (!AllocMemory(Self->AudioBufferSize, MEM::DATA, &Self->AudioBuffer)) {
if (AllocMemory(Self->AudioBufferSize, MEM::DATA, &Self->AudioBuffer) IS ERR::Okay) {
#ifdef _DEBUG
snd_pcm_hw_params_dump(hwparams, log);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/audio/class_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ static ERR AUDIO_SetVolume(extAudio *Self, struct sndSetVolume *Args)

if (Args->Name) {
for (index=0; index < std::ssize(Self->Volumes); index++) {
if (!StrMatch(Args->Name, Self->Volumes[index].Name.c_str())) break;
if (StrMatch(Args->Name, Self->Volumes[index].Name.c_str()) IS ERR::Okay) break;
}

if (index IS (LONG)Self->Volumes.size()) return ERR::Search;
Expand Down
18 changes: 9 additions & 9 deletions src/audio/class_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ static ERR SOUND_Activate(extSound *Self, APTR Void)
sndMixStop(*audio, Self->ChannelIndex);

if (sndMixSample(*audio, Self->ChannelIndex, Self->Handle) IS ERR::Okay) {
if (sndMixVolume(*audio, Self->ChannelIndex, Self->Volume)) return log.warning(ERR::Failed);
if (sndMixPan(*audio, Self->ChannelIndex, Self->Pan)) return log.warning(ERR::Failed);
if (sndMixFrequency(*audio, Self->ChannelIndex, Self->Playback)) return log.warning(ERR::Failed);
if (sndMixPlay(*audio, Self->ChannelIndex, Self->Position)) return log.warning(ERR::Failed);
if (sndMixVolume(*audio, Self->ChannelIndex, Self->Volume) != ERR::Okay) return log.warning(ERR::Failed);
if (sndMixPan(*audio, Self->ChannelIndex, Self->Pan) != ERR::Okay) return log.warning(ERR::Failed);
if (sndMixFrequency(*audio, Self->ChannelIndex, Self->Playback) != ERR::Okay) return log.warning(ERR::Failed);
if (sndMixPlay(*audio, Self->ChannelIndex, Self->Position) != ERR::Okay) return log.warning(ERR::Failed);

return ERR::Okay;
}
Expand Down Expand Up @@ -774,15 +774,15 @@ static ERR SOUND_Init(extSound *Self, APTR Void)
ERR error;

if (!Self->AudioID) {
if ((error = snd_init_audio(Self))) return error;
if ((error = snd_init_audio(Self)) != ERR::Okay) return error;
}

// Open channels for sound sample playback.

if (!(Self->ChannelIndex = glSoundChannels[Self->AudioID])) {
pf::ScopedObjectLock<extAudio> audio(Self->AudioID, 3000);
if (audio.granted()) {
if (!sndOpenChannels(*audio, audio->MaxChannels, &Self->ChannelIndex)) {
if (sndOpenChannels(*audio, audio->MaxChannels, &Self->ChannelIndex) IS ERR::Okay) {
glSoundChannels[Self->AudioID] = Self->ChannelIndex;
}
else {
Expand Down Expand Up @@ -825,11 +825,11 @@ static ERR SOUND_Init(extSound *Self, APTR Void)
// Read the FMT header

Self->File->seek(12, SEEK::START);
if (flReadLE(Self->File, &id)) return ERR::Read; // Contains the characters "fmt "
if (flReadLE(Self->File, &len)) return ERR::Read; // Length of data in this chunk
if (flReadLE(Self->File, &id) != ERR::Okay) return ERR::Read; // Contains the characters "fmt "
if (flReadLE(Self->File, &len) != ERR::Okay) return ERR::Read; // Length of data in this chunk

WAVEFormat WAVE;
if (Self->File->read(&WAVE, len, &result) or (result < len)) {
if ((Self->File->read(&WAVE, len, &result) != ERR::Okay) or (result < len)) {
log.warning("Failed to read WAVE format header (got %d, expected %d)", result, len);
return ERR::Read;
}
Expand Down
4 changes: 0 additions & 4 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ target_link_libraries (core PRIVATE zlib)

if (PARASOL_STATIC)
target_link_libraries (core PRIVATE ${LIB_LIST})

if (X11_Xrandr_FOUND)
target_link_libraries (core PRIVATE xrandr)
endif ()
endif ()

if (WIN32)
Expand Down
18 changes: 9 additions & 9 deletions src/core/classes/class_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static ERR FILE_Activate(extFile *Self, APTR Void)
if ((Self->Flags & FL::DEVICE) != FL::NIL) {
openflags |= O_NOCTTY; // Prevent device from becoming the controlling terminal
}
else if (!StrCompare("/dev/", path, 0)) {
else if (StrCompare("/dev/", path, 0) IS ERR::Okay) {
log.warning("Opening devices not permitted without the DEVICE flag.");
return ERR::NoPermission;
}
Expand Down Expand Up @@ -1374,7 +1374,7 @@ static ERR FILE_SetDate(extFile *Self, struct flSetDate *Args)
#elif __unix__

CSTRING path;
if (!GET_ResolvedPath(Self, &path)) {
if (GET_ResolvedPath(Self, &path) IS ERR::Okay) {
struct tm time;
time.tm_year = Args->Year - 1900;
time.tm_mon = Args->Month - 1;
Expand Down Expand Up @@ -1546,7 +1546,7 @@ static ERR FILE_Watch(extFile *Self, struct flWatch *Args)
}
else error = log.warning(ERR::SystemCall);

if (error) return error;
if (error != ERR::Okay) return error;
}
#endif

Expand All @@ -1559,7 +1559,7 @@ static ERR FILE_Watch(extFile *Self, struct flWatch *Args)
#ifdef _WIN32
if (AllocMemory(sizeof(rkWatchPath) + winGetWatchBufferSize(), MEM::DATA, (APTR *)&Self->prvWatch, NULL) IS ERR::Okay) {
#else
if (!AllocMemory(sizeof(rkWatchPath), MEM::DATA, (APTR *)&Self->prvWatch, NULL)) {
if (AllocMemory(sizeof(rkWatchPath), MEM::DATA, (APTR *)&Self->prvWatch, NULL) IS ERR::Okay) {
#endif
Self->prvWatch->VirtualID = vd->VirtualID;
Self->prvWatch->Routine = *Args->Callback;
Expand Down Expand Up @@ -1886,7 +1886,7 @@ ERR SET_Date(extFile *Self, DateTime *Date)
CSTRING path;
time_t datetime;
struct utimbuf utm;
if (!GET_ResolvedPath(Self, &path)) {
if (GET_ResolvedPath(Self, &path) IS ERR::Okay) {
struct tm time;
time.tm_year = Date->Year - 1900;
time.tm_mon = Date->Month - 1;
Expand Down Expand Up @@ -2152,7 +2152,7 @@ static ERR GET_Link(extFile *Self, STRING *Value)

*Value = NULL;
if ((Self->Flags & FL::LINK) != FL::NIL) {
if (!ResolvePath(Self->Path, RSF::NIL, &path)) {
if (ResolvePath(Self->Path, RSF::NIL, &path) IS ERR::Okay) {
LONG i = StrLength(path);
if (path[i-1] IS '/') path[i-1] = 0;
if (((i = readlink(path, buffer, sizeof(buffer)-1)) > 0) and ((size_t)i < sizeof(buffer)-1)) {
Expand Down Expand Up @@ -2320,7 +2320,7 @@ static ERR GET_Permissions(extFile *Self, PERMIT *Value)
// process could always have changed the permission flags.

CSTRING path;
if (!GET_ResolvedPath(Self, &path)) {
if (GET_ResolvedPath(Self, &path) IS ERR::Okay) {
LONG i = StrLength(path);
while ((i >= 0) and (path[i] != '/') and (path[i] != ':') and (path[i] != '\\')) i--;
if (path[i+1] IS '.') Self->Permissions = PERMIT::HIDDEN;
Expand Down Expand Up @@ -2408,7 +2408,7 @@ static ERR set_permissions(extFile *Self, PERMIT Permissions)
// File represents a folder

CSTRING path;
if (!GET_ResolvedPath(Self, &path)) {
if (GET_ResolvedPath(Self, &path) IS ERR::Okay) {
LONG flags = 0;
if ((Permissions & PERMIT::READ) != PERMIT::NIL) flags |= S_IRUSR;
if ((Permissions & PERMIT::WRITE) != PERMIT::NIL) flags |= S_IWUSR;
Expand Down Expand Up @@ -2609,7 +2609,7 @@ static ERR SET_Size(extFile *Self, LARGE Size)
// Seek past the file boundary and write a single byte to expand the file. Yes, it's legal and works.

ERR error;
if (!(error = GET_ResolvedPath(Self, &path))) {
if ((error = GET_ResolvedPath(Self, &path)) IS ERR::Okay) {
struct statfs fstat;
if (statfs(path, &fstat) != -1) {
if (Size < (LARGE)fstat.f_bavail * (LARGE)fstat.f_bsize) {
Expand Down
10 changes: 5 additions & 5 deletions src/core/classes/class_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ static ERR TASK_Activate(extTask *Self, APTR Void)
buffer[i++] = ' ';

if (!path) path = Self->Location;
if (!ResolvePath(path, RSF::APPROXIMATE|RSF::PATH, &path)) {
if (ResolvePath(path, RSF::APPROXIMATE|RSF::PATH, &path) IS ERR::Okay) {
for (j=0; (path[j]) and ((size_t)i < sizeof(buffer)-1);) buffer[i++] = path[j++];
FreeResource(path);
}
Expand All @@ -860,7 +860,7 @@ static ERR TASK_Activate(extTask *Self, APTR Void)

// Resolve the location of the executable (may contain an volume) and copy it to the command line buffer.

if (!ResolvePath(Self->Location, RSF::APPROXIMATE|RSF::PATH, &path)) {
if (ResolvePath(Self->Location, RSF::APPROXIMATE|RSF::PATH, &path) IS ERR::Okay) {
for (j=0; (path[j]) and ((size_t)i < sizeof(buffer)-1);) buffer[i++] = path[j++];
buffer[i] = 0;
FreeResource(path);
Expand Down Expand Up @@ -1423,7 +1423,7 @@ static ERR TASK_Init(extTask *Self, APTR Void)

for (len=0; buffer[len]; len++);
while ((len > 1) and (buffer[len-1] != '/') and (buffer[len-1] != '\\') and (buffer[len-1] != ':')) len--;
if (!AllocMemory(len+1, MEM::STRING|MEM::NO_CLEAR, (void **)&Self->ProcessPath, NULL)) {
if (AllocMemory(len+1, MEM::STRING|MEM::NO_CLEAR, (void **)&Self->ProcessPath, NULL) IS ERR::Okay) {
for (i=0; i < len; i++) Self->ProcessPath[i] = buffer[i];
Self->ProcessPath[i] = 0;
}
Expand All @@ -1433,7 +1433,7 @@ static ERR TASK_Init(extTask *Self, APTR Void)
if (getcwd(buffer, sizeof(buffer))) {
if (Self->Path) { FreeResource(Self->Path); Self->Path = NULL; }
for (len=0; buffer[len]; len++);
if (!AllocMemory(len+2, MEM::STRING|MEM::NO_CLEAR, (void **)&Self->Path, NULL)) {
if (AllocMemory(len+2, MEM::STRING|MEM::NO_CLEAR, (void **)&Self->Path, NULL) IS ERR::Okay) {
for (i=0; buffer[i]; i++) Self->Path[i] = buffer[i];
Self->Path[i++] = '/';
Self->Path[i] = 0;
Expand Down Expand Up @@ -2089,7 +2089,7 @@ static ERR SET_Path(extTask *Self, CSTRING Value)

#ifdef __unix__
STRING path;
if (!ResolvePath(new_path, RSF::NO_FILE_CHECK, &path)) {
if (ResolvePath(new_path, RSF::NO_FILE_CHECK, &path) IS ERR::Okay) {
if (chdir(path)) {
error = ERR::InvalidPath;
log.msg("Failed to switch current path to: %s", path);
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ static ERR init_volumes(const std::forward_list<std::string> &Volumes)
if (size < 1) size = 8192;

STRING buffer;
if (!AllocMemory(size, MEM::NO_CLEAR, (APTR *)&buffer, NULL)) {
if (AllocMemory(size, MEM::NO_CLEAR, (APTR *)&buffer, NULL) IS ERR::Okay) {
size = read(file, buffer, size);
buffer[size] = 0;

Expand Down
Loading

0 comments on commit 96268d7

Please sign in to comment.