Skip to content

Commit

Permalink
[Update] - time
Browse files Browse the repository at this point in the history
  • Loading branch information
vvaucoul committed Jul 22, 2024
1 parent 34e452a commit a29008b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 38 deletions.
41 changes: 20 additions & 21 deletions Hephaistos/libs/string/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: vvaucoul <vvaucoul@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/20 11:31:06 by vvaucoul #+# #+# */
/* Updated: 2024/07/20 20:10:09 by vvaucoul ### ########.fr */
/* Updated: 2024/07/22 13:22:34 by vvaucoul ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -58,25 +58,24 @@ inline int32_t strncmp(const char *s1, const char *s2, uint32_t n) {
return (__strncmp(s1, s2, n));
}

extern char *strtrtc(const char *str, const char c);
extern char *strclr(char *new_str, char *str);
extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, uint32_t n);
extern char *strcat(char *dest, const char *src);
extern char *strjoin(char *s1, char *s2);
extern char *strchr(const char *s, int c);
extern char *strrchr(const char *s, int c);
extern char *strdup(const char *s);
extern char *strndup(const char *s, uint32_t n);
extern char *strtrim(char const *s);
extern char *strsub(char const *s, unsigned int start, uint32_t len);
extern char **strsplit(char const *s, char c);
extern char *strtok(char *str, const char *delim);
extern char *strstr(const char *haystack, const char *needle);
extern char *strpbrk(const char *s, const char *accept);
extern char *strrev(char *str);
extern char *strrevp(char *str, uint32_t start, uint32_t end);

extern int isspace(char c);
char *strtrtc(const char *str, const char c);
char *strclr(char *new_str, char *str);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, uint32_t n);
char *strcat(char *dest, const char *src);
char *strjoin(char *s1, char *s2);
char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);
char *strdup(const char *s);
char *strndup(const char *s, uint32_t n);
char *strtrim(char const *s);
char *strsub(char const *s, unsigned int start, uint32_t len);
char **strsplit(char const *s, char c);
char *strtok(char *str, const char *delim);
char *strstr(const char *haystack, const char *needle);
char *strpbrk(const char *s, const char *accept);
char *strrev(char *str);
char *strrevp(char *str, uint32_t start, uint32_t end);
int isspace(char c);

#endif /* !_STRING_H */
61 changes: 44 additions & 17 deletions Hephaistos/libs/time/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,65 @@
/* ::: :::::::: */
/* time.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvaucoul <vvaucoul@student.42.Fr> +#+ +:+ +#+ */
/* By: vvaucoul <vvaucoul@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/21 14:11:09 by vvaucoul #+# #+# */
/* Updated: 2022/12/03 23:43:19 by vvaucoul ### ########.fr */
/* Updated: 2024/07/22 20:57:53 by vvaucoul ### ########.fr */
/* */
/* ************************************************************************** */

#include "time.h"
#include <charon.h>

void counter_start(counter_t *counter)
{
/**
* @brief Starts the time counter by recording the current timer ticks as the start time.
*
* @param counter Pointer to the counter structure to be started.
*/
void counter_start(counter_t *counter) {
assert(counter != NULL);
counter->start = timer_ticks;
}

void counter_stop(counter_t *counter)
{
/**
* @brief Stops the time counter by recording the current timer ticks as the end time.
*
* @param counter Pointer to the counter structure to be stopped.
*/
void counter_stop(counter_t *counter) {
assert(counter != NULL);
counter->end = timer_ticks;
}

uint32_t counter_get_start(counter_t *counter)
{
return (counter->start);
/**
* @brief Retrieves the start time of the counter.
*
* @param counter Pointer to the counter structure.
* @return The start time of the counter.
*/
uint32_t counter_get_start(counter_t *counter) {
assert(counter != NULL);
return counter->start;
}

uint32_t counter_get_end(counter_t *counter)
{
return (counter->end);
}

uint32_t counter_get_time(counter_t *counter)
{
return (counter->end - counter->start);
/**
* @brief Retrieves the end time of the counter.
*
* @param counter Pointer to the counter structure.
* @return The end time of the counter.
*/
uint32_t counter_get_end(counter_t *counter) {
assert(counter != NULL);
return counter->end;
}

/**
* @brief Calculates the elapsed time between the start and end of the counter.
*
* @param counter Pointer to the counter structure.
* @return The elapsed time between the start and end times of the counter.
*/
uint32_t counter_get_time(counter_t *counter) {
assert(counter != NULL);
return counter->end - counter->start;
}

0 comments on commit a29008b

Please sign in to comment.