Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request Issue #35 nanosleep #46

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zakgilbert
Copy link

Was able to get nanosleep working

int main(int argc, char *argv[])
{
    init_hash_colors();
    image_t img;
    char *file;
    char *num;
    int c;
    struct timespec req;  // <-------------  
    
    req.tv_sec = 0;     // <-------------
    opterr = 0;
    uint32_t cols = 0, precision = 0;
    uint8_t convert = 0;
    uint8_t true_color = 1;

Declared the timespec struct above main in catimg.c , wasn't sure where you wanted it.

struct timespec {
    time_t tv_sec;  /* seconds */       
    long   tv_nsec; /* nanoseconds */   
};

I tested multiple gifs and provided them in the test-gifs directory, goku.gif is my only concern, as hes going super sayan way quicker with the nanosleep.

I checkout the gif in gimp and the background layer is labled as Background (1000ms) as where every other layer is formated such as frame 1 (40ms) (combine). Not sure what the deal is. But besides for this, everything (all the other gifs I tested) appears to look very close to the same.

@zakgilbert zakgilbert changed the title Pull request issue #35 nanosleep Pull request Issue #35 nanosleep Mar 19, 2019
@zakgilbert
Copy link
Author

Issue #35

@posva
Copy link
Owner

posva commented Jun 30, 2019

Sorry for the huge delay!
I tried this on OSX and it errors out with a redefinition of time spec:

Scanning dependencies of target catimg
[ 20%] Building C object CMakeFiles/catimg.dir/src/catimg.c.o
/Users/posva/catimg/src/catimg.c:41:8: error: redefinition of 'timespec'
struct timespec {
       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_timespec.h:33:1: note: previous definition is here
_STRUCT_TIMESPEC
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_timespec.h:29:40: note: expanded from macro '_STRUCT_TIMESPEC'
#define _STRUCT_TIMESPEC        struct timespec
                                       ^
1 error generated.
make[2]: *** [CMakeFiles/catimg.dir/src/catimg.c.o] Error 1
make[1]: *** [CMakeFiles/catimg.dir/all] Error 2
make: *** [all] Error 2

Using an #ifndef around the struct seems to make it work. Could you share the 2 or 3 of the gifs you tested with?

src/catimg.c Show resolved Hide resolved
@zakgilbert
Copy link
Author

I apologize, its been so long. First of all, this program, in my opinion, reaches into the highest branches of top notchery, so good on you @posva, most people can't reach that high.

As for myself, I'll look into this issue a bit more.

@posva
Copy link
Owner

posva commented Sep 10, 2019

No worries! Take the time you need
And thank you so much for the kind words 😄

@E5ten
Copy link

E5ten commented Jun 19, 2020

timespec should be getting defined by time.h already, I don't see the need for defining the struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants